As long as the two locks are distinguishable somehow, this can easily be solved with a variation on the 'standard' trick:
This works because:
(If the two locks are indistinguishable, there is of course no way to determine which key unlocks which lock.)
Now you have one lock open and have eliminated a key, so ask the same question to the other guard, pointing at the remaining unopened lock.
If the question needs to be asked simultaneously of both guards, then we need to add a little more information, so it becomes: