Overview
Line in the sand is an idiom with two similar meanings:
The first meaning is of a point (physical, decisional, etc.) beyond which one will proceed no further. An example would be a person who might agree to visit a bar with his friends, but will go no further (i.e. not partake in drinking alcohol).
The second meaning is that of a point of no return, when the decision to go beyond it and its consequences become permanent and irreversible. An example would be to commit funds to completing a project (as opposed to deferral or cancellation); once committed, the funds cannot be spent on another activity, and the project will either succeed or fail.
Origin
Biblical link to John 8 (John 8:6). Some have (perhaps erroneously) interpreted Jesus' writing in the sand, as drawing a line in the sand in order to address those who are about to stone a woman caught in adultery. However, the literal translation is not that he drew a line in the sand, but that he "wrote" (or "drew lines" in some translations) in the sand, an important distinction.
The exact origin of the phrase is unknown: the Oxford English Dictionary suggests a transitional use from 1950, but a definitely figurative use only as late as 1978:
There is reference to an actual line being drawn in several historical, or legendary, military events:
From Wikipedia (CC BY-SA 4.0).