About the only known dog worm that can infect a human when in contact with the dog is the worm known as roundworm.
Other worms such as heartworms aren't known to be able to infect humans so a human can be around a dog with heartworms without fear of getting the heartworm from the dog.