If you're dealing with a mild infection, there are ways to manage the pain until it clears: Use over-the-counter pain medication or ear drops for pain relief, apply a cold or warm cloth to the affected ear, and try not to sleep on it.
Persistent or severe ear infections may require intervention from a doctor. Antibiotics, such as amoxicillin, can be used to help clear up infections. For children, placing small tubes in the ear to help with drainage can also be a solution if ear infections keep coming back or to help drain remaining fluid.