Take down a peg or two
To 'take (or pull, or bring) down a peg (or two)' is to lower someone's high opinion of themselves.
Various quantities and qualities have been measured by the use of pegs. It has been suggested that the pegs in question here were those used to regulate the amount of drink taken from a barrel, or those that controlled the hoisting of the colours (flags) of ships. Either of these might be correct although, like the 'yards' of 'the whole nine yards', 'pegs' could relate to many things.
It is interesting though that all the early citations of the phrase have a religious context; for example:
Pappe with An Hatchet, 1589 - "Now haue at you all my gaffers of the rayling religion, tis I that must take you a peg lower."
Joseph Mead's Letters, 1625 - "A-talking of the brave times that would be shortly... when... the Bishop of Chester, that bore himself so high, should be hoisted a peg higher to his little ease."
Samuel Butler's Hudibras, 1664 - "We still have worsted all your holy Tricks,... And took your Grandees down a peg."
If the pegs were some religious artefact, it isn't clear what they were. Lacking any real evidence, we can't be sure of the origin.