Organisms utilize environmental cues to deal with heterogeneous environments. In this sense, behaviours that mediate interactions between organisms and their environment are complex traits, especially sensitive to environmental conditions. In animals, olfaction is a critical sensory system that allows them to acquire chemical information from the environment. The genetic basis and physiological mechanisms of the olfactory system of Drosophila melanogaster Meigen (Diptera: Drosophilidae) are well known, but the effects of ecological factors on the olfactory system have received less attention. In this study, we analysed the effect of environmental heterogeneity (different host fruits) on variation in larval olfactory behaviour in a natural population of D. melanogaster. We generated half-sib lines of D. melanogaster derived from two nearby fruit plantations, Vitis vinifera L. (Vitaceae) (‘grape’) and Prunus persica L. (Rosaceae) (‘peach’), and measured, using a simple behavioural assay, larval olfactory response to natural olfactory stimuli. Results indicate that patterns of variation for this trait depend on host fruit plantation where lines were collected. In fact, only lines derived from ‘grape’ showed phenotypic plasticity for larval olfaction, whereas a genotype*environment interaction was detected solely in lines derived from ‘peach’. Therefore, our results demonstrate the existence of genetic differences in D. melanogaster larval olfactory behaviour at a micro-geographical scale and also reveal that the trait studied presents a dynamic genetic architecture which is strongly influenced by the environment.