Conventional wisdom says you should only cook with wine you'd actually drink. Serious Eats put that rule to the test and found that the quality of the wine doesn't have as much impact on flavour as other characteristics.
How sweet and acidic a wine is will affect the dish much more. A slightly sweet Riesling, for example, can get close to syrupy when reduced, and a Sauvingnon Blanc will become extremely tart, almost lemony, Daniel Gritzer writes.
As for cheap versus expensive wines, don't bother splurging:
For the past few weeks, I've been cooking nonstop with wine, both red and white, to explore the effects of their flavour on a dish. I've compared light reds to big, tannic ones; fruity, tart whites to buttery ones that have spent plenty of time in oak barrels; off-dry (read: slightly sweet) wines to dry ones; cheap wines to expensive ones; and long cooking methods to quick ones.* What I've found is that while certain characteristics of a wine will have an impact on the final dish, in most instances those differences are relatively subtle. In many cases, it makes little to no difference at all.
Even old, spoiled wine can taste good when cooked off. Serious Eats recommends using cask wine for your cooking.