The only guaranteed way to prevent a syphilis infection is to avoid sexual contact or only to have sexual contact with a faithful partner who has been tested and is not infected.
Condoms can reduce your risk of catching syphilis, but cannot prevent it altogether. You can still catch syphilis if your mouth makes contact with a sore on an infected person's anus or vagina, for example.
It is important not only to use a condom during vaginal, oral and anal sex, but also consider using a dental dam when your mouth makes contact with your partner's vagina or anus.
Avoid sharing sex toys. If you do share them, wash them or cover them with a condom before each use.