Hi, and thanks for your question.
Though not impossible, a person would be unlikely to get an STI from the type of contact you describe. If a person had an infection like syphilis or herpes that can be passed by skin to skin contact and they touched that area of themselves immediately prior to touching you, it might be possible to pass the virus or bacteria to you. Or if they had ejaculate on their own finger before touching your urethra they could possibly pass chlamydia or gonorrhea if they had either one of those infections.
Of course, those conditions would need to be in place, and really the risk from the encounter you describe is more theoretical than actual.
If you are sexually active, we do always recommend regular testing for sexually transmitted infections (STIs) anyways. To locate a testing provider in your area, have a look at our Clinic Finder
You might also find our Know Your Chances charts helpful in understanding how different STIs can be passed.
Let us know if this does not answer your question or if you have any more questions or concerns.
Health Nurse