Animals, from insects to humans, select foods to regulate their acquisition of key nutrients in amounts and balances that maximise fitness. In species in which the nutrition of juveniles depends on parents, adults must make challenging foraging decisions that simultaneously address their own nutrient needs as well as those of their progeny. Here, we examined how the fruit fly Drosophila melanogaster, a species in which individuals eat and lay eggs in decaying fruits, integrate feeding decisions (individual nutrition) and oviposition decisions (offspring nutrition) when foraging. Using cafeteria assays with artificial diets varying in concentrations and ratios of protein to carbohydrates, we show that D. melanogaster females exhibit complex foraging patterns, alternating between laying eggs on high carbohydrate foods and feeding on foods with different nutrient contents depending on their own nutritional state. Although larvae showed faster development on high protein foods, both survival and learning performance were higher on balanced foods. We suggest that the apparent mismatch between the oviposition preference of females for high carbohydrate foods and the high performances of larvae on balanced foods reflects a natural situation where high carbohydrate ripened fruits gradually enrich in proteinaceous yeast as they start rotting, thereby yielding optimal nutrition for the developing larvae. Our findings that animals with rudimentary parental care uncouple feeding and egg-laying decisions in order to balance their own diet and provide a nutritionally optimal environment to their progeny reveal unsuspected levels of complexity in the nutritional ecology of parent-offspring interactions.