If you know you don't have a punctured eardrum, you can use homemade preventive eardrops of 1 part white vinegar to 1 part rubbing alcohol. This solution promotes drying and helps prevent the growth of bacteria and fungi. Before and after swimming, pour 1 teaspoon (about 5 milliliters) of the solution into each ear and let it drain back out. More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.