Remind me of an ear infection I had, I also went deaf in one ear for quite some time.
The reason for you going deaf in that ear is that your eardrum has accumulated so much pressure that it burst. If its anything like mine, you should have felt no pain when you could not hear. That because the drum was burst and the pressure was gone. The reason it is hurting you now is because the drum repaired itself but is once again gaining pressure from the infection. Whatever medicine you were given obviously is not working. If not properly treated it will eventually burst again and the cycle will repeat.