It stems from the generic use of the term to mean a small and seemingly unimportant entity (the tail) controls a bigger, more important one (the dog). The phrase originates in the saying "a dog is smarter than its tail, but if the tail were smarter, then it would wag the dog."