Opioid use disorder (OUD) is a multifaceted condition influenced by sex, genetic and environmental factors that could be linked with epigenetic changes. Understanding how these factors interact is crucial to understand and address the development and progression of this disorder. Our aim was to elucidate different potential epigenetic and genetic mechanisms between women and men that correlate with OUD under real‐world pain unit conditions. Associations between analgesic response and the DNA methylation level of the opioid mu receptor (OPRM1) gene (CpG sites 1–5 selected in the promoter region) were evaluated in 345 long opioid‐treated chronic non cancer pain: cases with OUD (n = 67) and controls (without OUD, n = 278). Cases showed younger ages, low employment status and quality of life, but higher morphine equivalent daily dose and psychotropic use, compared to the controls. The patients with OUD showed a significant decrease in OPRM1 DNA methylation, which correlated with clinical outcomes like pain relief, depression and different adverse events. Significant differences were found at the five CpG sites studied for men, and exclusively in women for CpG site 3, in relation to OUD diagnosis. These findings support the importance of epigenetics and sex as biological variables to be considered toward efficient OUD understanding and therapy development.