When each of us dies, our souls are immediately taken to the presence of God and judged. This is called the Particular Judgment. At this point we begin our eternal destiny. If we are going to hell, our souls go directly there. If we are deemed worthy of heaven, our souls will go directly to heaven, or if we are going to heaven but are in need of purification (probably the vast majority of us), we may go to Purgatory first for a while (everyone in Purgatory will eventually go to heaven). Whatever our fate, our souls will stay there (heaven or hell) until the end of time, at which time the Second Coming will occur.
At the Second Coming at the end of time, those Christians still alive will be taken to heaven (what some Protestants think of as of the rapture). Then will occur the General Judgment. At that time the souls of the living and the dead will be reunited with their bodies and brought together in God’s presence and judged before all. Those who have already been judged in the Particular Judgment will be brought from wherever their souls were -heaven, hell or Purgatory-- and have their judgment confirmed before all, so that both the justice and mercy of God will be manifest to all.
After this, time and Purgatory will be no more and all will enter with their souls and bodies into their eternal destiny, either hell or heaven.
This is an extremely bare-bones sketch, so if you want to get the details, see the five articles I linked below: