It's a term from the world of horse racing. "The winner won by a head," means that the winner was one horse's head in front of the second place finisher. (One can also win by "a nose," meaning that it was a close race.) As with many sports idioms you can use these phrases in normal situations metaphorically to describe a victory.