It comes from the NT, where our LORD Himself warned about the “Gehenna of fire”.
Better to go into life eternal one handed, one footed or one eyed than to go whole bodied into Gehenna of fire. (Especially since in life eternal, you receive pneumatikon soma, anyhow

).
Earlier, in one of the prophets (Zechariah?) there is a reference to worms that will not die ,and to fires that will not be quenched, upon the bodies of YHWH’s enemies. This would have to be in an afterlife, because a dead body cannot be “punished.” Our LORD quotes this prophecy in HIS NT teaching on Gehenna.
Gehenna of fire comes from a valley, called Hinnom, outside the walls of Jerusalem where the city’s debris was burnt; this included unclaimed dead bodies. Obviously, the former owners of the bodies did not experience this as punishment, nor were the fires at Hinnom “unquenchable.” It was a metaphor for punishment in a realm beyond death.
Alleluia, ICXC NIKA!