No, there is no risk for this. Herpes requires direct, unclothed, skin to skin contact to transmit, like kissing, oral sex, or penetrative sex.
However, this is not a sanitary thing to do. There may be yeast, e coli, or other things on the panties. Also, if someone isn't aware that you are doing this to their underwear, it's a huge violation.