Adaptations to infectious and dietary pressures shape mammalian physiology and disease risk. How such adaptations affect sex-biased diseases remains insufficiently studied. In this study, we show that sex-dependent hepatic gene programs confer a robust (~300%) survival advantage for male mice during lethal bacterial infection. The transcription factor B cell lymphoma 6 (BCL6), which masculinizes hepatic gene expression at puberty, is essential for this advantage. However, protection by BCL6 protein comes at a cost during conditions of dietary excess, which result in overt fatty liver and glucose intolerance in males. Deleting hepatic BCL6 reverses these phenotypes but markedly lowers male survival during infection, thus establishing a sex-dependent trade-off between host defense and metabolic systems. Our findings offer strong evidence that some current sex-biased diseases are rooted in ancient evolutionary trade-offs between immunity and metabolism.