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. Knowing whether or not Onesiphorus was dead at the time Paul wrote his second epistle to Timothy is not necessary in order for the text to make sense.
Perhaps Onesiphorus was alive and simply away from home. So Paul had an urge to pray for his companion's family. What the text does indicate is that the two were not together. As this resource explains:
"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 Christianity was persecuted under the Roman Empire. A prayer for perseverance to the end would, by definition, mean that he was still alive. These notes from Dr. Thomas Constable are also pertinent here:
"Onesiphorus’ household was an exception to the “all” above (v. 15), or perhaps they had felt differently and had later reaffirmed their loyalty to Paul. In any case his family had diligently and unashamedly sought out Paul and had ministered to him during his current imprisonment. For this Paul wished the Lord would show Onesiphorus “mercy” at the judgment seat of Christ (cf. “that day” in v. 12). Because Onesiphorus had “found” Paul, Paul hoped that Onesiphorus would “find” mercy from the Lord. Paul seems to have been envisioning a scene in which all his brethren would stand before the Lord, Onesiphorus among them, namely, Christ’s judgment seat. God would express displeasure with the failure of the others, but Onesiphorus would escape that shame (cf. 1 John 2:28). Paul again used the possibility of shame to motivate Timothy (cf. v. 8). Timothy knew about Onesiphorus’ earlier faithful ministry in Ephesus. Paul referred to this as well to encourage Timothy to throw in his lot with Onesiphorus and his family rather than with those who had turned against the chained apostle."
"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." (E. H. Plumptre, D. D.)
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 Onesiphorus nor supporting the idea of anybody else doing such.