Transmission primarily occurs during vaginal delivery when the baby comes into contact with HSV present in the mother's genital tract. The risk of transmission is significantly higher if the mother has an active genital herpes infection at the time of delivery. Less commonly, transmission can occur in utero or postnatally through contact with infected individuals.