As long as the two locks are distinguishable somehow, this can easily be solved with a variation on the 'standard' trick:
First, assign each person a lock: "Let's say that lock 1 "belongs to" guard A, and lock 2 "belongs to" guard B."
Then ask the question: "If I asked you yesterday which key opened your lock, what is one key you might have pointed to? [¹]"
[¹] As Trenin points out, you need a clause here like "...assuming that if you are the liar, your algorithm is to point to any wrong answer, rather than defaulting to a particular wrong answer", to avoid the case where the liar is deterministic.
This works because:
The truthteller will obviously point to their own key - if you had asked them yesterday, they would tell the truth, and so today they will tell the truth about their hypothetical answer, and point to the correct key.
But what about the liar?If you had asked the question "Which key opens your lock?" to the liar, the correct answer could be either of the two wrong keys.
So instead, you ask the hypothetical "What would you have answered, if I had asked you that?" To lie about yesterday's answer, they must point to their own key, because anything else would be telling the truth.
(If the two locks are indistinguishable, there is of course no way to determine which key unlocks which lock.)