Just like in humans, a spasm in the diaphragm, the muscle under the lungs, causes hiccups in dogs.
Puppies will sometimes get hiccups after eating or drinking too fast, when they are tired, when they are very excited, or when they're too cold.
Scientists don't actually know why humans, dogs, and other mammals hiccup.