Not something that's happened to me with a bike, but I've very rarely been in a situation where I locked my bike. However, similar to hiding a key outside your house or under the bumper of your car, you can stash a spare key on the bike, in the seatpost, end of the handle bar, in the steerer, or something similar. Barring that, call for a ride home to get your spare key, call a locksmith, or buy a angle grinder and extension cord at a nearby hardware store.