Your friend needs to be seen by a doctor.
With an ear infection that bad, perhaps he should call his Dr and have them prescribe correct pain meds...
No one here can possibly tell you its okay for your friend to take a non-prescribed opiate. He needs to ask his doctor about this. Good luck.