The integrity of myelinated axons relies on homeostatic support from oligodendrocytes (OLs). To determine how OLs detect axonal spiking and how rapid axon–OL metabolic coupling is regulated in the white matter, we studied activity-dependent calcium (Ca2+) and metabolite fluxes in the mouse optic nerve. We show that fast axonal spiking triggers Ca2+ signaling and glycolysis in OLs. OLs detect axonal activity through increases in extracellular potassium (K+) concentrations and activation of Kir4.1 channels, thereby regulating metabolite supply to axons. Both pharmacological inhibition and OL-specific inactivation of Kir4.1 reduce the activity-induced axonal lactate surge. Mice lacking oligodendroglial Kir4.1 exhibit lower resting lactate levels and altered glucose metabolism in axons. These early deficits in axonal energy metabolism are associated with late-onset axonopathy. Our findings reveal that OLs detect fast axonal spiking through K+ signaling, making acute metabolic coupling possible and adjusting the axon–OL metabolic unit to promote axonal health.