"residence of a military commander," 1640s, from head (adj.) + quarters. Headquarter as a verb is recorded from 1838 (in Headquartered).
Entries linking to headquarters
head adj.
"most important, principal, leading," c. 1200, from head (n.). Old English heafod was used in this sense in compounds.
quarters n.
"military dwelling place," 1590s, from quarter (n.1) in sense of "portion of a town." As "part of an American plantation where the slaves live," from 1724. The military sense seems to be also the source of quartermaster and it might be behind the phrase give quarter "spare from immediate death" (1610s, often in the negative), on the notion of "provide a prisoner with shelter;" see quarter (n.2).