A key function of the brain is to filter essential information and store it in the form of stable, long-term memory (LTM). We demonstrate here that the Dunce (Dnc) phosphodiesterase, an important enzyme that degrades cAMP, acts as a molecular switch that controls LTM formation in Drosophila. We show that, during LTM formation, Dnc is inhibited in the SPN, a pair of newly characterized serotonergic neurons, which stimulates the cAMP/PKA pathway. As a consequence, the SPN activates downstream dopaminergic neurons, opening the gate for LTM formation in the olfactory memory center, the mushroom body. Strikingly, transient inhibition of Dnc in the SPN by RNAi was sufficient to induce LTM formation with a training protocol that normally generates only short-lived memory. Thus, Dnc activity in the SPN acts as a memory checkpoint to guarantee that only the most relevant learned experiences are consolidated into stable memory.