The ability to learn progressively declines with age. Neural hyperactivity has been implicated in impairing cognitive plasticity with age, but the molecular mechanisms remain elusive. Here, we show that chronic excitation of the Caenorhabditis elegans O2-sensing neurons during ageing causes a rapid decline of experience-dependent plasticity in response to environmental O2 concentration, whereas sustaining lower activity of O2-sensing neurons retains plasticity with age. We demonstrate that neural activity alters the ageing trajectory in the transcriptome of O2-sensing neurons, and our data suggest that high-activity neurons redirect resources from maintaining plasticity to sustaining continuous firing. Sustaining plasticity with age requires the K+-dependent Na+/Ca2+ (NCKX) exchanger, whereas the decline of plasticity with age in high-activity neurons acts through calmodulin and the scaffold protein Kidins220. Our findings demonstrate directly that the activity of neurons alters neuronal homeostasis to govern the age-related decline of neural plasticity and throw light on the mechanisms involved.