This question is probably tricky to answer accurately. One possibility is probably to look when ancient people and societies started to be seriously interested in history of earlier tribes or started to develop myths and legends like Achilles of Troja. It's not far from making up history to be interested in history. Can you give examples when first a king/tribe started to act clearly (in noted argumentation, unreasonable expensive wars/buildings) in a way to push his historical fame in the future (this means not only for the next living generation, every father wants to impress his family and relatives) but for decades, centuries. When did ancient people start to get interested also not only in their recent history, but history happening centuries ago?
Certainly from at least the time of Hammurabi and his Code of Laws, circa 1780 B.C., as the excerpt below readily shows (translated by L. W. King):
If that is not a pitch to history for everlasting fame and glory, I can't think of what might be.
It is theorized that ancient Proto-Indo-Europeans (4000-3000 BC) considered fame and glory as a form of (at least symbolic) immortality. Thus earning war glory was very important for their warriors.
The memory of their deeds was transmitted in oral form by poets.
In connection with this, one should mention the reconstructed expression in PIE language cleu̯os ndhğhitom (retained in Greek as kleos aphiton, Old Indic sravas aksitam) dated to PIE time, which means "imperishable fame" (literally, "non-burnable").