Dogs howl when music is played because they want to try to copy the harmonica sound and they want to add to the noise. In wolves, the dog's ancestor, each dog howls on their own note and will not howl on the same note as another.
Some scientists have taken this to mean that dogs like the cacophonous sounds made when howling on different notes. Dogs sometimes like to howl when they hear their humans sing or play another instrument such as the flute or guitar because they want to be a part of the "pack" just like they would if they were out in the wild as a wolf. It is difficult to know exactly what is going on in the mind of the dog when they vocalize, but copying the harmonica sound or joining in with the person playing the harmonica seem to be the most likely reasons why a dog would howl when its owner played the harmonica.
Researchers have also found that dogs have their own musical tastes and can sense the tone or pitch of a note. A dog that is left alone may also howl so that its humans or other dog companions in the home will come and find it. Dogs are not solitary animals and enjoy the companionship of their owners and their dog companions.