You get genital herpes by coming into contact with the herpesvirus. This can occur during oral, vaginal, or anal sex. It can also occur during intimate skin-to-skin contact that doesn’t include intercourse. Genital herpes in a pregnant woman can also be transmitted to the baby during pregnancy or childbirth.