Syphilis can be prevented by using protection during sexual activity, getting tested regularly for sexually transmitted infections, and avoiding sexual contact with partners who have syphilis or other sexually transmitted infections.