Hi,Thanks for query,
It seems that you might have there may be injury
where foreskin is attached to penis and while doing intercourse or forceful masturbation
if there is swelling and pain then go for antibiotic medicines.
Take plenty of water for passing concentrated urine.
Ok and bye.