Opioids are often prescribed to relieve the intense pain that accompanies a serious injury or surgical procedure. While opioids can be addictive, they are considered safe and effective for acute pain management if used for the shortest length of time and at the lowest effective dose necessary. A doctor who prescribes opioids for pain management should regularly monitor your pain levels with the goal of safely discontinuing their use when your pain is more manageable (or under control).
When starting recovery from opioid addiction, it's important to first consult a healthcare provider. They can help you create a treatment plan for your symptoms of withdrawal that will include a combination of therapy and medication.