The answer is either Intelligence or Wisdom, but which will depend on what kind of process you are trying to represent. You aren’t describing deduction, but rather induction, which is an important part of understanding which Ability to use.
Intelligence
The PHB describes intelligence (pg. 177) as:
… mental acuity, accuracy of recall, and the ability to reason.
If you are trying to represent the character’s ability to recall what the lock or key looked like, or to logically determine a relationship between them, then Intelligence is the Ability to use.
Intelligence is almost the perfect answer for the question as you posed it. Deduction is almost definitely an Intelligence based activity without exception. Except that you aren’t describing deduction, but rather induction.
Deduction may look something like, “All simple, aged copper locks can only be opened by simple, aged copper keys. I want to open a simple, aged copper lock, therefore I must require a simple, aged copper key.” However, deduction requires assumptions that are absolutely true. Is it really true that all key-lock combinations share traits like this? Why can’t an iron key open a copper lock? For example, suppose that a replacement key were created at some point. It may use different materials and styles.
So the kind of inference you are looking for is probably not deduction, and may not even be Intelligence based.
But Really Wisdom
The PHB describes Wisdom (pg. 178) as:
… how attuned you are to the world around you and represents perceptiveness and intuition.
If you want to represent whether a character has noticed something, or is able to reach a conclusion based on intuition rather than reason, then Wisdom is the way to go.
The logical process you are describing is inductive, and a much better match for Wisdom. An inductive process may look something like, “So far, all the locks I have seen are opened by keys made from the same material and in the same style as the lock they open. Therefore, I think that all locks are opened by keys in the same material and style as the lock.”
To me, this sounds like what you are trying to describe. The character is trying to intuit a relationship between locks and keys based on their own experience and observation. Wisdom is a much better fit than intelligence.
Now, if the player still has a problem determining that they should use a simple, aged copper key for their simple, aged copper lock an Intelligence check would be appropriate, because this has become a deductive problem.