Addiction is a chronic disorder involving recurring intoxication, withdrawal, and craving episodes. Escaping this vicious cycle requires maintenance of abstinence for extended periods of time and is a true challenge for addicted individuals. The emergence of depressive symptoms, including social withdrawal, is considered a main cause for relapse, but underlying mechanisms are poorly understood. Here we establish a mouse model of protracted abstinence to heroin, a major abused opiate, where both emotional and working memory deficits unfold. We show that delta and kappa opioid receptor (DOR and KOR, respectively) knockout mice develop either stronger or reduced emotional disruption during heroin abstinence, establishing DOR and KOR activities as protective and vulnerability factors, respectively, that regulate the severity of abstinence. Further, we found that chronic treatment with the antidepressant drug fluoxetine prevents emergence of low sociability, with no impact on the working memory deficit, implicating serotonergic mechanisms predominantly in emotional aspects of abstinence symptoms. Finally, targeting the main serotonergic brain structure, we show that gene knockout of mu opioid receptors (MORs) in the dorsal raphe nucleus (DRN) before heroin exposure abolishes the development of social withdrawal. This is the first result demonstrating that intermittent chronic MOR activation at the level of DRN represents an essential mechanism contributing to low sociability during protracted heroin abstinence. Altogether, our findings reveal crucial and distinct roles for all three opioid receptors in the development of emotional alterations that follow a history of heroin exposure and open the way towards understanding opioid system-mediated serotonin homeostasis in heroin abuse.