Patients with chronic postsurgical pain are commonly prescribed opioids chronically because of refractory pain although chronic opioid use can cause various severe problems. We aimed to investigate postoperative chronic opioid use and its association with perioperative pain management in patients who underwent a total knee arthroplasty in a Japanese real-world clinical setting. We conducted a retrospective cohort study using an administrative claims database. We used a multivariate logistic regression analysis to examine the association between perioperative analgesic and anesthesia prescriptions and postoperative chronic opioid use. We calculated all-cause medication and medical costs for each patient. Of the 23,537,431 patient records, 14,325 patients met the criteria and were included in the analyses. There were 5.4% of patients with postoperative chronic opioid use. Perioperative prescriptions of weak opioids, strong and weak opioids, and the α2δ ligand were significantly associated with postoperative chronic opioid use (adjusted odds ratio [95% confidence interval], 7.22 [3.89, 13.41], 7.97 [5.07, 12.50], and 1.45 [1.13, 1.88], respectively). Perioperative combined prescriptions of general and local anesthesia were also significantly associated with postoperative chronic opioid use (3.37 [2.23, 5.08]). These medications and local anesthesia were more commonly prescribed on the day following surgery, after routinely used medications and general anesthesia were prescribed. The median total direct costs were approximately 1.3-fold higher among patients with postoperative chronic opioid use than those without postoperative chronic opioid use. Patients who require supplementary prescription of analgesics for acute postsurgical pain are at high risk of postoperative chronic opioid use and these prescriptions should be given careful consideration to mitigate the patient burden.