Oh gosh, no advice but I am sometimes awful with this.
There is a friend of my best friend, who I have met countless times and I don't know his name, I am too ashamed to ask her, and it would now be highly inappropriate to ask him next time I see him!
I sometimes find, if it happens in a large group, to find someone you know and casually introduce, ie 'this is my friend 'x' and hopefully they will introduce themself to them and you can make a note.
lol