Your puppy is vomiting worms because it has worms. Most likely they are tape worms that the puppy has had since birth. New puppies are generally treated for these with their first vet check up which should have been done as soon as you got the puppy.