Opioids are used to treat moderate to severe pain, especially after medical, dental, or other surgical procedures.