It is probably derived from the vice versa "there is a key for every lock", which can be used to either mean there is a solution for every problem, or suggest that there is likely a way to unlock a person's heart so you can find your way inside, or more literally make them like or even fall in love with you. See the Thesaurus of Traditional English Metaphors by P.R. Wilkinson for reference. I suppose the other way around could be taken to mean that there is a problem for every solution, although that would not work as well metaphorically, because duplicate keys exist, which would explain why it is much less common.
However, taking note of the context, with the "can't find someone verbiage" and the immediate mention of a woman thereafter, it probably means that there is a woman for every man, which is a phrase used to reassure people that even if they have difficulty finding a mate, they can do so, if they try hard enough, because the sex distribution among humankind is approximately 50:50.
Take this excerpt from page 22 of Say Hello to Me by Darshaun McAway for example:
There's a woman for every man. Women are everywhere. The trick is, how do you find the right woman for you?
In this case the lock and key serve as metonymy for man and woman by way of acting as euphemisms for human genitals.
My advice is to avoid copying unfamiliar terms from Big Bang Theory unless you are ready to be embarrassed: It has many jokes which are designed to be socially awkward, because the show is meant to be about a group of nerds. This is almost certainly one of those jokes. Just use the more direct "woman for every man" language instead, and you can avoid potentially distasteful references to human genitals altogether.