Appropriate preferences for light or dark conditions can be crucial for an animal's survival. Innate light preferences are not static in some animals, including the fruit fly Drosophila melanogaster, which prefers darkness in the feeding larval stage but prefers light in adulthood. To elucidate the neural circuit underlying light preference, we examined the neurons involved in larval phototactic behavior by regulating neuronal functions. Modulating activity of two pairs of isomorphic neurons in the central brain switched the larval light preference between photophobic and photophilic. These neurons were found to be immediately downstream of pdf-expressing lateral neurons, which are innervated by larval photoreceptors. Our results revealed a neural mechanism that could enable the adjustment of animals' response strategies to environmental stimuli according to biological needs.