The transmission occurs transplacentally, meaning the bacteria cross the placenta. This can happen at any stage of pregnancy, but the risk is highest when the mother has untreated primary or secondary syphilis. The infection can also be transmitted during delivery if there are active lesions.