This nested case-control study examines the association of risk of infection with opioid use in immunocompromised patients.