Background and purpose: We aimed to examine the association between socioeconomic status (SES) markers and opioid use after primary total hip arthroplasty (THA) due to osteoarthritis, and whether sex, age, or comorbidities modify any association.Methods: Using Danish databases, we included 80,038 patients undergoing primary THA (2001–2018). We calculated prevalences and prevalence ratios (PRs with 95% confidence intervals [CIs]) of immediate post-THA opioid use (≥ 1 prescription within 1 month) and continued opioid use (≥ 1 prescription in 1–12 months) among immediate opioid users. Exposures were individual-based education, cohabitation, and wealth.Results: The prevalence of immediate opioid use was ~45% in preoperative non-users and ~60% in preoperative users (≥ 1 opioid 0–6 months before THA). Among non-users, the prevalences and PRs of continued opioid use were: 28% for low vs. 21% for high education (PR 1.28, CI 1.20–1.37), 27% for living alone vs. 23% for cohabiting (PR 1.09, CI 1.04–1.15), and 30% for low vs. 20% for high wealth (PR 1.43, CI 1.35–1.51). Among users, prevalences were 67% for low vs. 55% for high education (1.22, CI 1.17–1.27), 68% for living alone vs. 60% for cohabiting (PR 1.10, CI 1.07–1.12), and 73% for low wealth vs. 54% for high wealth (PR 1.32, CI 1.28–1.36). Based on testing for interaction, sex, age, and comorbidity did not statistically significant modify the associations. Nevertheless, associations were stronger in younger patients for all SES markers (mainly for non-users).Conclusion: Markers of low SES were associated with a higher prevalence of continued post-THA opioid use. Age modified the magnitude of the associations, but it was not statistically significant.