The timing of sex in facultatively sexual organisms is critical to fitness, due to the differing demographic consequences of sexual versus asexual reproduction. In addition to the costs of sex itself, an association of sex with the production of dormant life stages also influences the optimal use of sex, especially in environments where resting eggs are essential to survive unfavourable conditions. Here we document population dynamics and the occurrence of sexual reproduction in natural populations of Daphnia magna across their growing season. The frequency of sexually reproducing females and males increased with population density and with decreasing asexual clutch sizes. The frequency of sexually reproducing females additionally increased as population growth rates decreased. Consistent with population dynamic models showing that the opportunity cost of sexual reproduction (foregoing contribution to current population growth) diminishes as populations approach carrying capacity, we found that investment in sexual reproduction was highest when asexual population growth was low or negative. Our results support the idea that the timing of sex is linked with periods when the relative cost of sex is reduced due to low potential asexual growth at high population densities. Thus, a combination of ecological and demographic factors affect the optimal timing of sexual reproduction, allowing D. magna to balance the necessity of sex against its costs.