Organisms from slime moulds to humans carefully regulate their macronutrient intake to optimize a wide range of life history characters including survival, stress resistance, and reproductive success. However, life history characters often differ in their response to nutrition, forcing organisms to make foraging decisions while balancing the trade-offs between these effects. To date, we have a limited understanding of how the nutritional environment shapes the relationship between life history characters and foraging decisions. To gain insight into the problem, we used a geometric framework for nutrition to assess how the protein and carbohydrate content of the larval diet affected key life history traits in the fruit fly, Drosophila melanogaster. In no-choice assays, survival from egg to pupae, female and male body size, and ovariole number - a proxy for female fecundity - were maximized at the highest protein to carbohydrate (P:C) ratio (1.5:1). In contrast, development time was minimized at intermediate P:C ratios, around 1:2. Next, we subjected larvae to two-choice tests to determine how they regulated their protein and carbohydrate intake in relation to these life history traits. Our results show that larvae targeted their consumption to P:C ratios that minimized development time. Finally, we examined whether adult females also chose to lay their eggs in the P:C ratios that minimized developmental time. Using a three-choice assay, we found that adult females preferentially laid their eggs in food P:C ratios that were suboptimal for all larval life history traits. Our results demonstrate that D. melanogaster larvae make foraging decisions that trade-off developmental time with body size, ovariole number, and survival. In addition, adult females make oviposition decisions that do not appear to benefit the larvae. We propose that these decisions may reflect the living nature of the larval nutritional environment in rotting fruit. These studies illustrate the interaction between the nutritional environment, life history traits, and foraging choices in D. melanogaster, and lend insight into the ecology of their foraging decisions.