I searched for an explanation of the origin of this expression, but found mostly explanations for the meaning. Several sites explained it referred to a person who worked diligently and usually with no obvious benefit to the worker. Ask.com had the most likely explanation for the origin, and it refers to the process of “docking” an animal’s tail. Docking is the intentional removal of the tail or sometimes ears to prepare the animal for some sort of practical function. One example was the “docking” of the tail of a horse to make it easier to use the horse for hauling. That makes sense, since the horse has part of its tail removed despite the fact the horse is working hard to achieve a work task after having part of their tails removed with no obvious value to the horse.