1570s, "character on a staff to indicate its name and pitch," so that the others may be known, from Middle French clef (12c.) "key; musical clef; trigger," from a figurative or transferred use of classical Latin clavis, which had only the literally sense "key" (from PIE root *klau- "hook").
In the Middle Ages, the Latin word was used in the Guidonian system for "the lowest note of a scale," which is its basis (see keynote). The most common is the treble, violin, or G-clef, which crosses on the second line of the staff, denoting that as the G above middle C on the piano.