Thanks for your query.Based on the facts that you have posted it appears that you have ring worm infection
of the penile and scrotal skin.
This could result from a dry vigorous masturbation
resulting in to minor scratches on the skin which get infected with contamination of a inner wares .
Please consult qualified dermatologist
for clinical examination and further treatment.
You may need to take anti fungal medication
like Fluconozole orally and anti fungal jelly like Meconazole for local application.for 4-5 days.