I don't think it's a simple, one-step decision, so I doubt a question like yours has a clear answer.
It does seem to be the case that modern human mentality--by which I mean the combination of complex communication and cognition phenomena that underlies both art and belief in the supernatural--laid the basis for the possibility of worship. Prehistoric cave art suggests these mental behaviors existed by 40,000 BCE.
From then on, humans appear to have had the abilities to imagine what they hadn't seen, to discuss what they'd imagined, and to tie emotional responses to physical representations.
Probably, the concept of "gods" derives from that imaginative capacity, just like the more recent comic-book concept of "superheroes." But the concept needs to be tied to an emotional response, most likely either fear or gratitude, to result in worship.
But even given the possibility of worship, the decision to offer worship is not simple. I don't think either "need" or "learned behavior" really covers the range of available bases for the decision. You've left out the possibility of a reasoned determination that it's simply fitting.
Much of my background reading on the development of human minds comes from Richard Leakey's "The Origin of Humankind." I've revised the dating based on more recent reports of discoveries of older prehistoric art.