Animals select their optimal environmental temperature, even when faced with alternatives that differ only slightly. This behavior is critical as small differences in temperature of only several degrees can have a profound effect on the survival and rate of development of poikilothermic animals, such as the fruit fly. Here, we demonstrate that Drosophila larvae choose their preferred temperature of 17.5 degrees C over slightly cooler temperatures (14-16 degrees C) through activation of chordotonal neurons. Mutations affecting a transient receptor potential (TRP) vanilloid channel, Inactive (Iav), which is expressed specifically in chordotonal neurons, eliminated the ability to choose 17.5 degrees C over 14-16 degrees C. The impairment in selecting 17.5 degrees C resulted from absence of an avoidance response, which is normally mediated by an increase in turns at the lower temperatures. We conclude that the decision to select the preferred over slightly cooler temperatures requires iav and is achieved by activating chordotonal neurons, which in turn induces repulsive behaviors, due to an increase in high angle turns.