Importance: Most prisons and jails in the US discontinue medications for opioid use disorder (MOUD) upon incarceration and do not initiate MOUD prior to release., Objective: To model the association of MOUD access during incarceration and at release with population-level overdose mortality and OUD-related treatment costs in Massachusetts., Design, Setting, and Participants: This economic evaluation used simulation modeling and cost-effectiveness with costs and quality-adjusted life-years (QALYs) discounted at 3% to compare MOUD treatment strategies in a corrections cohort and an open cohort representing individuals with OUD in Massachusetts. Data were analyzed between July 1, 2021, and September 30, 2022., Exposures: Three strategies were compared: (1) no MOUD provided during incarceration or at release, (2) extended-release (XR) naltrexone offered only at release from incarceration, and (3) all 3 MOUDs (naltrexone, buprenorphine, and methadone) offered at intake., Main Outcomes and Measures: Treatment starts and retention, fatal overdoses, life-years and QALYs, costs, and incremental cost-effectiveness ratios (ICERs)., Results: Among 30 000 simulated incarcerated individuals with OUD, offering no MOUD was associated with 40 927 (95% uncertainty interval [UI], 39 001-42 082) MOUD treatment starts over a 5-year period and 1259 (95% UI, 1130-1323) overdose deaths after 5 years. Over 5 years, offering XR-naltrexone at release led to 10 466 (95% UI, 8515-12 201) additional treatment starts, 40 (95% UI, 16-50) fewer overdose deaths, and 0.08 (95% UI, 0.05-0.11) QALYs gained per person, at an incremental cost of $2723 (95% UI, $141-$5244) per person. In comparison, offering all 3 MOUDs at intake led to 11 923 (95% UI, 10 861-12 911) additional treatment starts, compared with offering no MOUD, 83 (95% UI, 72-91) fewer overdose deaths, and 0.12 (95% UI, 0.10-0.17) QALYs per person gained, at an incremental cost of $852 (95% UI, $14-$1703) per person. Thus, XR-naltrexone only was a dominated strategy (both less effective and more costly) and the ICER of all 3 MOUDs compared with no MOUD was $7252 (95% UI, $140-$10 018) per QALY. Among everyone with OUD in Massachusetts, XR-naltrexone only averted 95 overdose deaths over 5 years (95% UI, 85-169)-a 0.9% decrease in state-level overdose mortality-while the all-MOUD strategy averted 192 overdose deaths (95% UI, 156-200)-a 1.8% decrease., Conclusions and Relevance: The findings of this simulation-modeling economic study suggest that offering any MOUD to incarcerated individuals with OUD would prevent overdose deaths and that offering all 3 MOUDs would prevent more deaths and save money compared with an XR-naltrexone-only strategy.