We explored behavioural plasticity in the use of aggregation pheromone in the fruit fly Drosophila melanogaster Meigen (Diptera: Drosophilidae). Based on previous field observations, we formulated two hypotheses on a benefit of using aggregation pheromone for aggregated oviposition. One hypothesis concerns a benefit to the females themselves, where reduced harassment by males can enhance oviposition rate; the other concerns a benefit to their offspring, where larvae can exploit arduous substrates more efficiently. We derive contrasting expectations on the strength of the behavioural response to pheromone for substrates that differ in nutritional quality to larvae. High quality substrates relax the strength of larval competition, which allows for stronger aggregative responses of the females, but conversely, it may yield aggregation less necessary when the benefit is related to resource exploitation by the larvae. In indoor and outdoor dual choice set-ups, we tested the behavioural responses of the adults to the aggregation pheromone with substrates of varying quality, and examined oviposition behaviour. The response of adults to the aggregation pheromone was strong and robust for low quality substrates, but significantly weaker for a high quality substrate. This supports the hypothesis on a benefit to the larvae. Females retained aggregation pheromones in the absence of oviposition substrates for at least 24 h. In the outdoor set-up, substrate with aggregation pheromone received more than three times as many eggs as control substrates, and this was directly related to the number of adults that visited each substrate. Per capita, oviposition rates were not different for differently sized aggregations, and consequently, no evidence was found in support of the hypothesis on reduced harassment. The combination of aggregation pheromone possession and a mutualistic relationship with microorganisms for Drosophila and other insects is discussed.