If you look closely at your dog's rectum, you will see two very small "holes" on either side of their rectum opening. These are the openings to the anal glands. (the "holes" are about the size of a pierced ear opening, for lack of a better description!) If the glands need expressing, you will be able to feel to either side of those little openings that they are full--the "glands" will feel like pea-sized or slightly larger if they need expressing. If you do express them, as the others have already said--the smell is not very pleasant and it lingers....its best to do it at bath time and in the tub preferably in case they "shoot" it will be much easier to clean up!
Most dogs express their glands on their own when they have a bowel movement. some dogs--not all--need a bit of help in that department from time to time. many small toy breed dogs (toy poodles and chihuahuas especially) are notorious for having problems with their anal glands. Normal anal sac discharge should be clear or pale yellowish in color; if it is thick, pasty or brownish or greenish-yellow in color than there may be an infection or impaction. In those cases, the vet will need to be sure that they are fully expressed and then instill an antibiotic ointment into the infected sacs.