How a healthcare provider tests for syphilis depends on what stage of the disease you are in.
If you have something that may be a syphilis sore (chancre), the doctor will swab the region and look at the sample under a dark field microscope to see if any Treponema pallidum, the bacteria that cause syphilis, are present. Doctors may also use direct fluorescent antibody testing to detect T. pallidum in the sample.
There is also a blood test for syphilis; however, it is not good at detecting primary syphilis. It may miss as many as 1/3 of these early cases, which is why dark field microscopy is the gold standard for early diagnosis. This is also why many doctors who do not have access to a dark field microscope will presumptively treat sores that look like syphilis, even if the blood test for syphilis is negative.
The syphilis blood test looks for antibodies to the disease. It does not directly detect the bacteria, but it does let your provider know if you have been infected with syphilis. However, it is important to know that the antibodies can stay around for years after successful treatment of a syphilis infection. Therefore, if you have been previously treated for syphilis, you should tell your provider in advance. If you change doctors, it's a good idea to get copies of any blood tests for your next doctor.
Note: If you are pregnant, you should ask your doctor to perform a blood test for syphilis. Untreated syphilis during pregnancy can be fatal to the developing baby.
Dowell et al. (2009) "Dilemmas in the Management of Syphilis: A Survey of Infectious Diseases Experts" Clinical Infectious Diseases. 49 (Nov 15):EPub Ahead of Print (accessed 10/24/09)