If someone contracts syphilis, how long do they have to receive treatment?

Depends on form. The preferred treatment for newly acquired (primary)syphillis is a single dose of penicillin g with avoidance of sexual activity until any primary leasons are healed. Followup blood tests at 6 & 12 months are recomended to verify the success of initial treatment or recurrance. Weekly pcn x3 is recomended for latent disease. Since other std's often co-exist variations in rx are often needed.
No limit. There's no limit--syphilis can be treated at any time--but treating sooner is better, in part to avoid developing serious illness, and also to avoid spreading it to others. Primary, secondary, and early latent syphilis (within a year of infection) can be treated with1 shot of penicillin, but after a year, you need 3 shots, and if there is neurologic involvement, you need prolonged IV therapy.