Oh, this is something I can answer - at least for the Army. I do believe the other branches of service use the same types of dogs, though.
, the Army has patrol dogs, patrol/narcotics dogs and patrol/explosives dogs, as well as SSDs (Specialized Search Dogs) that are trained for explosives only.
The Army manual that covers military working dogs is AR 190-12. If you Google it, you can download it on the Internet. It does not tell you how the dogs are trained, only how they are used, information about kennel facilities, and that sort of thing.
Patrol Dogs are used to protect installation facilities, prevent crime, and provide law enforcement services. They are used as a deterrent on patrols, as a way of finding a fleeing person (especially at night), and to go after and hold someone running from military police.
Explosives Detector Dogs are trained in detection, tracking, and building search. They are also sometimes used to help other federal agencies when there is a need for explosives dogs in a situation.
Narcotics Detector Dogs are trained in detection, tracking, and building search. Difference being they are trained to detect narcotics, not explosives.
Now, throughout history, military working dogs have been used for a lot of other purposes, such as being messenger dogs (carrying a message between two handlers), casualty dogs (finding wounded soldiers on the battlefield), off-leash and on-leash tracker dogs, and mine and tunnel dogs (trained to locate mines/tunnels in Vietnam).
There are also currently two black Labradors in the US Army who are trained as Therapy Dogs and who are deployed to Iraq with a medical (combat stress control) unit.