Thanks for your query,based on the facts that you have posted it appears that you have developed painful ulcer over under surface of foreskin mostly due to dry ,vigorous .
unprotected (?)sex .
Please get swab test of a fluid from ulcer done to rule out possibility of acquiring STD
You need to take broad spectrum antibiotic like Cefexine along with anti inflammatory drug like Diclofenac
twice daily.along with topical antibiotic
ointment like Neosporin
Ensure to wash your genitals with warm water twice daily
Ensure to avoid sexual encounters till it heals up completely.