There is no way of decisively knowing whether or not Onesiphorus was dead when the Apostle Paul wrote this epistle. Inferences can certainly be drawn in debating such a question, but the context of this verse does not conclusively rule in favor of either side. Further, knowing whether or not Onesiphorus was dead at the time Paul wrote 2 Timothy is not necessary in order for the text to make sense to us.
Perhaps Onesiphorus was alive and simply away from home, so Paul had an urge to pray for his companion's family. What we can gather from this text beyond a reasonable doubt is that the two were not together at the time. One commentator says the following: "Knowing that even these good deeds could not save Onesiphorus and his house, the apostle asks the Lord to show mercy to his friend — to keep him in the grace of God that he might persevere until the very end." This makes perfect sense because Christians were persecuted during this time. A prayer for perseverance to the end would, by definition, mean that he was still alive.
Even if Onesiphorus was dead at this point in time, that would only mean the apostle was petitioning God to show mercy to the man and his family on the Day of Judgment. After all, he was very beneficial to Paul during his ministry. He wanted his household to be blessed as a result of his faithfulness and loyalty. This scenario would be similar to King David blessing the household of Jonathon and his descendants (2 Samuel 9:1-7). Paul would essentially be expressing a hope for Onesiphorus to be resting in peace. These comments from English divine and scholar Edward Hayes Plumptre are insightful here:
"It is, at any rate, clear that such a simple utterance of hope in prayer, like the Shalom (peace) of Jewish, and the Requiescat or Refrigerium of early Christian epitaphs, and the like prayers in early liturgies, though they sanction the natural outpouring of affectionate yearnings, are as far as possible from the full-blown Romish theory of purgatory."
Onesiphorus received complete forgiveness of sins at the moment of his conversion. If he was dead when Paul wrote 2 Timothy, then his fate was already sealed. No amount of prayers could possibly alter or help his eternal destiny. Paul was neither praying to him nor supporting the idea of anybody else doing such. He was not praying that Onesiphorus would be released from purgatory or anything in those lines.