Well, generally, most doctors, even general physicians are knowledgeable enough to treat STD's. You just have to be honest with your doctor when he/she asks you questions.
Generally, male patients are more comfortable going to male doctors. Women, likewise, go to female doctors.
Its important that STD's be treated as early as possible. There are a lot of possible complications, not to mention spreading it to other people, that may arise from untreated STD's.
If you're really very particular though, a male patient can go to a urologist, and a female patient can go to a female urologist (although there are still very few female urologists in the country), or to an OB-GYN.