Trade‐offs between current and future resource allocation can select for elevated reproductive effort in individuals facing mortality. Males are predicted to benefit from increasing investment in costly sexually selected signals after experiencing an acute life span reduction, although few examples of such facultative terminal investment are known. In the mealworm beetle, Tenebrio molitor, males’ odours become more attractive to females following a life‐threatening immune challenge. However, the pheromones involved are unknown, hindering further insight into the proximate mechanisms and ultimate consequences of terminal investment. Using chemical and behavioural analyses, we show that the cuticular hydrocarbons (CHCs) of T. molitor are sexually dimorphic and are used by females to locate and select males. Moreover, both male CHCs and glandular pheromones were affected by experimental immune challenge in a fashion that made them more attractive to females. The results suggest that males terminally invest in both short‐ and medium‐range pheromones when they perceive reduced future survival. Moreover, the constitutive and inducible aspects of male and female CHC production are consistent with sex‐specific selection on the signalling and defensive functions of CHCs. The implications of terminal investment for ‘dishonest’ signalling and the efficacy of sexual selection are discussed.