I usually just smile embarrassingly, bow my head, and apologize very quietly. It's usually not so bad because the other person often smiles back and apologizes as well.
It almost never happens to me with guys...maybe my thought processes are more feminine than masculine, which I'm alright with.