You have no risk.
Theoretically, herpes, HPV and syphilis are transmitted by direct skin to skin contact, but they need prolonged friction to transmit, usually the kind associated with intercourse, not what you have with a few brief seconds of contact.
Also, him rubbing off on you while your pants were up is not a risk. STDs don't go through clothing.
You have nothing to worry about here.