Anorexia and fasting are host adaptations to acute infection, inducing a metabolic switch towards ketogenesis and the production of ketone bodies, including β-hydroxybutyrate (BHB) 1-6. However, whether ketogenesis metabolically influences the immune response in pulmonary infections remains unclear. Here we report impaired production of BHB in humans with SARS-CoV-2-induced but not influenza-induced acute respiratory distress syndrome (ARDS). CD4+ T cell function is impaired in COVID-19 and BHB promotes both survival and production of Interferon-γ from CD4+ T cells. Using metabolic tracing analysis, we uncovered that BHB provides an alternative carbon source to fuel oxidative phosphorylation (OXPHOS) and the production of bioenergetic amino acids and glutathione, which is important for maintaining the redox balance. T cells from patients with SARS-CoV-2-induced ARDS were exhausted and skewed towards glycolysis, but can be metabolically reprogrammed by BHB to perform OXPHOS, thereby increasing their functionality. Finally, we demonstrate that ketogenic diet (KD) and delivery of BHB as ketone ester drink restores CD4+ T cell metabolism and function in respiratory infections, ultimately reducing the mortality of SARS-CoV-2 infected mice. Altogether, our data reveal BHB as alternative carbon source promoting T cell responses in pulmonary viral infections, highlighting impaired ketogenesis as a potential confounder of severe COVID-19.