When wondering about word origins, a good first stop in any decent dictionary, since they include the word's etymology. Or go straight to a specialist etymology dictionary, e.g. Etymonline:
cockpit (n.)
1580s, "a pit for fighting cocks," from cock (n.1) + pit (n.1). Used in nautical sense (1706) for midshipmen's compartment below decks; transferred to airplanes (1914) and to cars (1930s).