The brain regulates energy homeostasis in the organism. Under resource shortage, the brain takes priority over peripheral organs for energy supply. But can the brain also down-regulate its own consumption to favor survival? We show that the brain of Drosophila specifically disables the costly formation of aversive long-term memory (LTM) upon starvation, a physiological state required for appetitive LTM formation. At the neural circuit level, the slow oscillations normally triggered in two pairs of dopaminergic neurons to enable aversive LTM formation were abolished in starved flies. Transient artificial activation of these neurons during training restored LTM formation in starved flies but at the price of a reduced survival. LTM formation is thus subject to adaptive plasticity that helps survival under food shortage.