Welcome to HCM,
It seems that while doing masturbation
due to more excitement there might be some minor injury or bruise
giving rise to some infection resulting pain and swelling.
As there is itching there is possibility of having fungal infection
Apply triple action antibiotic cream.
Keep the part clean and healthy.
Ok and bye.