Physiological stress induces aversive memory formation and profoundly impacts animal behavior. In C.elegans, concurrent mitochondrial disruption induces aversion to the bacteria that the animal inherently prefers, offering an experimental paradigm for studying the neural basis of aversive memory. We find that, under mitochondrial stress, octopamine secreted from the RIC modulatory neuron targets the AIY interneuron through the SER-6 receptor to trigger learned bacterial aversion. RIC responds to systemic mitochondrial stress by increasing octopamine synthesis and acts in the formation of aversive memory. AIY integrates sensory information, acts downstream of RIC, and is important for the retrieval of aversive memory. Systemic mitochondrial dysfunction induces RIC responses to bacterial cues that parallel stress induction, suggesting that physiological stress activates latent communication between RIC and the sensory neurons. These findings provide insights into the circuit and neuromodulatory mechanisms underlying stress-induced aversive memory.