Thanks for posting your query.
First thing is why do you need pain medicine, in today's medicine there are so many good pain control drugs which do not cause dependence, you should consult a physician for them.
The fluttering heart rate
can be caused by a cardiac arrhythmia
which can be diagnosed by an ECG if it is all the time and by a Holter if it comes in spurts.
Your pain medicine can be a cause but arrhythmias can occur otherwise also.
Hope I have answered your query.
If you have any questions I will be happy to answer.
Please close the query if you have no other questions.
Wish you a good health.