Different interoceptive systems must be integrated to ensure that multiple homeostatic insults evoke appropriate behavioral and physiological responses. Little is known about how this is achieved. Using C. elegans, we dissect cross-modulation between systems that monitor temperature, O2 and CO2. CO2 is less aversive to animals acclimated to 15°C than those grown at 22°C. This difference requires the AFD neurons, which respond to both temperature and CO2 changes. CO2 evokes distinct AFD Ca2+ responses in animals acclimated at 15°C or 22°C. Mutants defective in synaptic transmission can reprogram AFD CO2 responses according to temperature experience, suggesting reprogramming occurs cell autonomously. AFD is exquisitely sensitive to CO2. Surprisingly, gradients of 0.01% CO2/second evoke very different Ca2+ responses from gradients of 0.04% CO2/second. Ambient O2 provides further contextual modulation of CO2 avoidance. At 21% O2 tonic signalling from the O2-sensing neuron URX inhibits CO2 avoidance. This inhibition can be graded according to O2 levels. In a natural wild isolate, a switch from 21% to 19% O2 is sufficient to convert CO2 from a neutral to an aversive cue. This sharp tuning is conferred partly by the neuroglobin GLB-5. The modulatory effects of O2 on CO2 avoidance involve the RIA interneurons, which are post-synaptic to URX and exhibit CO2-evoked Ca2+ responses. Ambient O2 and acclimation temperature act combinatorially to modulate CO2 responsiveness. Our work highlights the integrated architecture of homeostatic responses in C. elegans.