I'm going to be a bit more stern than I usually am. Taking pain medication your innocent animal needs to be comfortable is worse than just relapsing. If you can't control your addiction then you absolutely must find a home for your dog where it can get the care and medication it needs.
Opiate withdrawal is rough, but if you want sobriety, you can do this. Can you get into a rehab, or if more, what about suboxone or methadone? I'm sorry to come down so hard on you, but I'm an animal lover and I very protective of animals.