In phytophagous insects, oviposition behaviour is an important component of habitat selection and, given the multiplicity of genetic and environmental factors affecting its expression, is defined as a complex character resulting from the sum of interdependent traits. Here, we study two components of egg-laying behaviour: oviposition acceptance (OA) and oviposition preference (OP) in Drosophila melanogaster using three natural fruits as resources (grape, tomato and orange) by means of no-choice and two-choice experiments, respectively. This experimental design allowed us to show that the results obtained in two-choice assays (OP) cannot be accounted for by those resulting from no-choice assays (OA). Since the genomes of all lines used are completely sequenced, we perform a genome-wide association study to identify and characterize the genetic underpinnings of these oviposition behaviour traits. The analyses revealed different candidate genes affecting natural genetic variation of both OA and OP traits. Moreover, our results suggest behavioural and genetic decoupling between OA and OP and that egg-laying behaviour is plastic and context-dependent. Such independence in the genetic architectures of OA and OP variation may influence different aspects of oviposition behaviour, including plasticity, canalization, host shift and maintenance of genetic variability, which contributes to the adoption of adaptive strategies during habitat selection.