"means of fastening," Old English loc "bolt, fastening; barrier, enclosure," from Proto-Germanic *lukan (cf. Old Norse lok "fastening, lock," Gothic usluks "opening," Old High German loh "dungeon," German Loch "opening, hole," Dutch luik "shutter, trapdoor"). "The great diversity of meaning in the Teut. words seems to indicate two or more independent but formally identical substantival formations from the root."
The Old English sense "barrier, enclosure" led to the specific meaning "barrier on a river" (c.1300), and the more specific sense "gate and sluice system on a water channel used as a means of raising and lowering boats" (1570s). Wrestling sense is from c.1600. Phrase under lock and key attested from early 14c.