Great advice from dat and the Toad, but my own personal method for getting out of a complete disaster is first of all (as Clive Dunn would say in Dads Army) Don't panic......
The minute you panic....you have lost it, the audience imediately know you have made a mistake...for all they know losing the card, if that is the problem, is all part of the trick....
So here is what I would do, and have done on occasions....ask the spectator to keep thinking of their card....and go to another spectator and ask them to choose another card, now do a fantastic trick with this new spectator and blow them away......now come back to the first spectator and blatently ask them the name or their card while looking through the deck.....say I think your card has disapeared from the deck.
Now quickly find it and cull it or get it somehow to the top of the deck....there are methods of showing it's not in the deck and I have posted this in another post but anyway...you can now palm it off if you wish and produce it from your pocket, wallet, anywhere you like in fact.
Not ideal but gets you out of a situation.
If in fact we are not talking cards here, (as there are so many possible outs with cards) then I think you will have to resort to the advice of dat and practice, practice and more practice until the possibility of failure is so low that it's almost impossible.... that should be the main aim anyway, with any magic you show to lay people, but that's another story...
