The chair of the Democratic National Committee (currently Donna Brazile) would call a special meeting of the DNC, which is roughly a 447-person body. That body has the power to replace the party nominee, as far as the party is concerned. This is how the Democratic Party replaced Thomas Eagleton with Sargent Shriver as the VP candidate after the 1972 convention.
But how the DNC goes about making the choice — under what rules, through what process — is not spelled out further in the party rules.
On the Republican side, it would also be the Republican National Committee that would have the power to choose a replacement nominee (though the RNC is a smaller body, around 150 members, than the DNC).
Second, once the party comes up with a new nominee, the question becomes whether that candidate can now get on the ballot in various states to replace the convention’s nominee. This is an issue of state law, handled differently in different states. In some states, it is formally too late at this point to replace a party nominee for the presidential election. But the courts might well conclude that state laws that allow too short a time for replacement in the case of death or withdrawal, in a presidential election, are themselves unconstitutional.
Third, and finally, we are back to the question of how the electors vote. Suppose the convention’s nominee cannot be replaced on the ballot in time but has died or withdrawn. The party has chosen an alternative, through the process above, but that person can’t get on the ballot. And now voters who support the party — let’s say Democrats — vote for the Democratic candidate on the ballot, even though he or she has withdrawn, to express their support for the Democratic Party. What does the elector do?
We are now more or less back to the question and the scenario I described in the third case. Presumably the elector would like to vote for the person the Democratic Party has chosen to replace its nominee and does so. If state law prohibits that, is the state law unconstitutional? Is Congress obligated to accept this vote?