1640s, "gourd-like fruit, of a deep orange-yellow color when ripe, of a coarse decumbent vine native to North America," an alteration of pompone, pumpion "melon, pumpkin" (1540s), from French pompon, from Latin peponem (nominative pepo) "melon," from Greek pepon "melon." The Greek word is probably originally "ripe," on the notion of "cooked (by the sun)," from peptein "to cook" (from PIE root *pekw- "to cook, ripen"). With ending conformed to words in -kin.
Figuratively, in 19c. (and later) U.S. vernacular, it has meant both "stupid, self-important person" and "person or matter of importance" (as in some pumpkins).
Pumpkin-pie is recorded from 1650s. Pumpkin-head, American English colloquial for "person with hair cut short all around" is recorded by 1781. Vulgar American English alternative spelling punkin attested by 1806.
America's a dandy place:
The people are all brothers:
And when one's got a punkin pye,
He shares it with the others.
[from "A Song for the Fourth of July, 1806," in The Port Folio, Philadelphia, Aug. 30, 1806]