There can be many reasons for that.
You should see an ENT specialist or a family doctor with special interest in ENT to check further. You can google to look for them.
Sometimes, the earwax can expand and become painful.
Other times, it can be due to a ear infection, can be bacterial or fungal.
Rarely, it can be due to a hole in the eardrum.
In any case, you should let a medical professional look inside your ear.