According to Wikipedia:

Quote Originally Posted by Wikipedia
"Toe the line" is an idiomatic expression with disputed origins. It is often equivocated to "toe the mark," both of which mean to conform to a rule or a standard. One documented origin of the phrase is as an athletics analogy originated in the early 19th century. Other suggested origins are the center line in boxing which boxers were instructed to toe at the start of each round, or the lines created by deck planks on ships which naval crews used to “fall in line”. The longest running use of the phrase and its most likely origin is from the British House of Commons where sword strapped members were instructed to stand behind lines that were better than a sword’s length from their political rivals. Thus the cry to “toe the line!” was echoed to return order to the House and to quell a potential mortal conflict.
Link