I don't know when judgment occurs. The fate of humans is beyond the bounds of Arda, whereas Elves wait in the Halls of Mandos until they are reincarnated. This happened to Glorfindel, who after dying while killing a balrog in the First Age at the Fall of Gondolin, was reincarnated and appeared in The Fellowship of the Ring, helping the four hobbits and Aragorn to Imladris.
Beren is waiting in the Halls of Mandos when Luthien comes to sing before Mandos, so humans do apparently spend some time waiting before they are sent beyond Arda. What fate awaits humans outside Arda is not described anywhere in JRRT's legendarium, to my knowledge.
I think the fate of Saruman and Sauron help us to understand something of what happens to evil beings. These were Maia, so it might not apply to elves and humans, but their spirits/ghosts were blown into the East; we are left to assume that they either dissipated or were expelled to the uttermost void. There may be things I'm not aware of and I hope others can correct my mistakes.
|