The DM should decide based on the campaign world and PC history:
I'd say that this is mainly a DM decision, and depending on the type of gods in the world you are playing, might end with converting the PC to a NPC.
I once played a wizard that worshipped the god of knowledge. When they read some older than the gods scrolls the god got to know about some ancient knowledge and disappeared. As a consequence I lost my priest spells.
Some days later, we finished successfully the campaign. We were playing in a very heroic way and my character died in the last minute. The dragon we awoke (who was a lot more powerful than the gods) resurrected my PC to take the place of the lost god of knowledge. This was a reward from the DM for good role playing during all the campaign, and was a good and reasonable solution for the world we were playing.
Of course I lost the character anyway, but the next time we were playing within the same world it was nice to know that the god of Knowledge was my previous character.
So in summary, I think it should be something that
- fits the world
- fits the past of the character
- happens as a consequence of some very relevant success on the part of the PC
- DM and Players agree on it.