Dogs are amazing at smelling things. Part of the reason is because they, as well as a few other animals, have a special organ on the roof of their mouth called the vomeronasal organ (VNO) or Jacobson’s organ.
The VNO is like a second nose that connects to the mouth. When dogs sniff something interesting, they lick their nose and curl their lips. This moves some of the smell to the VNO, where it is sensed by special cells. The VNO then tells the brain what it "tasted." The VNO helps dogs to talk to each other and humans, and to find mates, enemies, food, and home.