Temperature is a critical environmental stimulus that has a strong impact on an organism's biochemistry. Animals can respond to changes in ambient temperature through behaviour or altered physiology. However, how animals habituate to temperature is poorly understood. The nematode C. elegans stores temperature experiences and can induce temperature habituation-linked cold tolerance. Here we show that light and pheromone-sensing neurons (ASJ) regulate cold habituation through insulin signalling. Calcium imaging reveals that ASJ neurons respond to temperature. Cold habituation is abnormal in a mutant with impaired cGMP signalling in ASJ neurons. Insulin released from ASJ neurons is received by the intestine and neurons regulating gene expression for cold habituation. Thus, temperature sensation in a light and pheromone-sensing neuron produces a robust effect on insulin signalling that controls experience-dependent temperature habituation.