Definition - the head, brain
Bean, referring to a thing one eats, has been in English for a very long time (since the 12th century); most of the word’s figurative meanings came about much later. Some which arose in the 20th century are the application of bean to mean either “the head” or “to strike (a person) on the head with an object.” Many of the earliest uses of this verb and noun come from the realm of baseball, but soon enough the noun was in use among writers such as P. G. Wodehouse, who employed it without any connection to sporting events.
Here, with a sniff like the tearing of a piece of calico, she buried the bean in her hands, and broke into what are called uncontrollable sobs.
— P. G. Wodehouse, The Code of The Woosters, 1938