Hello,
Thank you for your query at DoctorSpring.com
I understand your concern.
I have seen the images and this looks like injury due to the friction from your masturbation. This does not look like herpes sores. They present in clusters and are extremely painful, invariably associated with a rash extending up to the anus.
So, kindly do not worry. You need to avoid masturbation for at least 4-5 days, till there is recovery.
Hope this was helpful,
Regards.