Background and purpose – Total hip arthroplasty (THA) is an effective and common procedure. However, persistent pain and analgesic requirement up to 2 years after THA surgery are common. We examined the trends in the utilization of analgesics before and after THA, overall, and in relation to socioeconomic status (SES) in a populationbased cohort. Patients and methods – We used the Danish Hip Arthroplasty Register to identify 103,209 patients who underwent THA between 1996 and 2018. Data on prescriptions and SES markers was obtained from Danish medical databases. Prevalence rates of redeemed prescriptions for analgesics with 95% confidence intervals were calculated for 4 quarters before and 4 quarters after THA for the entire THA population, and by 3 SES markers (education, cohabiting status, and wealth). Results – Overall, the prevalence of analgesic use prior to surgery was 42% at 9-12 months and 59% at 0-3 months before the THA. The prevalence of analgesics reached its highest at 64% 0-3 months after THA but declined to 27% at 9-12 months after THA. Low education, living alone, and having low wealth (low SES) were associated with higher prevalence of analgesics use both before and after THA. Interpretation – 59% of patients used analgesics 0-3 months before surgery, which could indicate that THA might not be considered the last option for treatment and that surgery criteria might depend more on factors such as patient preferences or hip function. Moreover, health professionals should prioritize the use of a detailed plan when phasing out analgesics after THA to counteract unnecessary use, especially when treating patients with low SES.