The primary treatment for a Gardnerella vaginalis infection involves antibiotics such as metronidazole or clindamycin. These medications can be administered orally or as a vaginal gel. It is important to complete the full course of antibiotics even if symptoms improve to ensure the infection is fully eradicated.