thanks for your query at HCM
painful swelling behind the ear can be due to infection .
infection of hair follicle or skin around ear can cause swelling and pain.
take tab paracetomol that will decrease pain and swelling.
if there is fever
and headache get examined by doctor and take medication accordingly.