Hi. What you are experiencing is early
barotrauma to your ears because of the closure of your eustachian tube (connects the area behind the
nasal cavity to the middle ear which is behind the
eardrum) when you go inside water. This is similar to the ear blockage that occurs during an aircraft decent before landing.
The reason for the pain is the stretching of the ear drum when it is being pulled inwards due to rising negative pressure in the middle ear. Ideally, when we are outside water, the eustachian tube equalizes the middle ear pressure to the atmospheric pressure. But when inside water, it is unable to do so since it fills up with water or collapses under pressure beneath the water and causes negative pressure to build within the middle ear.
I believe that there must have been some eustachian tube
injury or swelling the first time you experienced the problem. Following which without adequate healing subsequent underwater experiences have been painful. I would suggest that you allow the eustachian tube some time to heal, maybe 3 to 4 weeks before you swim again. Steam inhalation, saline nasal sprays and oral decongestant medications will help speed the recovery (See an ENT for a decongestant prescription). Also, when you restart to swim, avoid diving or going deep inside water for a few times before you start feeling confident of doing so again without
ear pain.
Ear plugs will not help because the problem is not from the outer
ear canal. A hearing test may be recommended since these episodes effect hearing over the long run.