This means either the underwear is too small or you have skin-related issues with the material. First, check the size and make sure it's the right fit.
If it's health-related, then you can pick another pair of underwear that has a different type of material and also seek medication just in case it's an infection.
Another option for men is to try boxer briefs that will protect one's legs from rubbing while running.