mid-15c., from Middle Dutch pegge "peg," a common Low German word (Low German pigge "peg," German Pegel "gauge rod, watermark," Middle Dutch pegel "little knob used as a mark," Dutch peil "gauge, watermark, standard"), of uncertain origin; perhaps from PIE *bak- "staff used as support" (see bacillus). To be a square peg in a round hole "be inappropriate for one's situation" is attested from 1836; to take someone down a peg is from 1580s, but the original literal sense is uncertain (most of the likely candidates are not attested until centuries later). Peg leg "wooden leg" attested from 1765.
"fasten with or as if on a peg," 1590s, from peg (n.). Slang sense of "identify, classify" first recorded 1920. Related: Pegged; pegging.