The treatment isn't the same for all worms. Many, but not all.
Fenbendazole is available at the pet store and works against a bunch of different types of common dog worms. That's what you'll see on the shelves at the pet store as an "8 in 1" dewormer.
It is not effective against Dipylidium tapeworms (which unfortunately is a common one in dogs):
Evaluation of granulated fenbendazole as a treatment for helminth infections in dogs. - PubMed - NCBI
Dipylidium tapeworms are treated with praziquantel, which unfortunately is only available with a prescription.