If you are struggling to get off of addictive painkillers or heroin then there are a few steps you can take to deal with this. The easiest path to take is to check into a local treatment center or drug rehab facility. Once there, they can help you to get physically detoxed from the drug and also to start learning of new ways to deal with life without resorting to self medicating behavior. They will also introduce you to support from others who are going through recovery as well.
There are other options for treating opiate addiction too, such as by using drug therapy. Some people would argue that this is not an ideal solution, and can create more problems in the long run than what it solves. But for some people it seems to be the only thing that works.