I am wracking my brain for this episode. I think it was a Next Generation episode, but I can't find it on the list of their episodes. The ship comes across a small vessel which contains an alien from another dimension. The alien was supposed to be dead, since it is a funeral vessel, but he is still alive.
The alien starts to question his faith, since our dimension is obviously not Heaven. The "funeral vessels" are all crashed on an asteroid or moon, however. In the end, it is found that the moon has some strange electromagnetic field that may be a result of the energy from the other dead aliens. So perhaps that moon is a form of heaven for them.
The episode did a good job of exploring issues of death and the afterlife. I was hoping to share it with a trekkie friend who just lost a loved one. Please help if you can remember it.