Guido hit the nail on the head. Opiates start out as being "better than viagra" for sex. Everything StartedHydro said is correct. This is usually on lower doses of "weaker" opiates, when they are still having great effect.
It DOESN"T stay that way though. Eventually when your doses get too high, or your sick often as not, you get times when you cannot get hard or blow if your life depended on it. Take too much Opana? Lucky if you can walk to the fridge, let alone get hard. Got no opiates in you today? Good luck fucking while sick as a dog. After awhile it becomes more of a shot in the dark: will this be the time you fuck better than Peter North or will it be the time your a limp dicked guy who cant get his girl off?
I would say the only way to treat this is to stop doing opiates. They fuck with your libido, testosterone, and cock. Not something most people wanna fuck with; ended up making me skinny as hell (to name one effect of testosterone loss) and bitchy, now i gotta work mad hard to put weight back on. For others this resulting hormone imbalance can make them fat and passive. Hormones fuck with everyone differently, which is why we're all born with our body releasing X amount over Y time. Best not to fux with it too much, especially before youre fully done growing.