In an era of global warming, the negative effects of temperature stress on fertility could intensify predicted losses of biodiversity. Male fertility is particularly sensitive to temperature stress, yet we have an incomplete understanding of when, during reproductive ontogeny, spermatogenesis is most affected. Here, we used a temperature-switch protocol to identify when during development temperature affects the expression of sperm length and testes size in the bruchid beetle Callosobruchus maculatus. Egg-to-adult development took place at 17°C, 27°C or 33°C for either the full duration of pre-imago development or it was switched at different stages during development. Full development at 17°C or 33°C resulted in significantly shorter sperm than at 27°C. However, when developing larvae were switched to higher or lower temperatures, we observed switch-specific phenotypic expression of sperm length and testes size. Our key finding was that sperm length was sensitive to high-temperature stress during the early stages of ontogeny and to low-temperature stress during the latter stages of ontogeny. Such age-specific developmental sensitivity suggests that infertility resulting from transient heat stress (i.e. heatwaves) could be mitigated by age-related developmental heterogeneity within populations. Those individuals able to avoid severe effects of heat stress on fertility, through serendipitously being at less-sensitive stages of development, could potentially compensate for the loss of fertility experienced by those individuals at more sensitive stages of development.