Number 2 is correct.
Hard work is the key to passing examinations.
It is very difficult to give a simple explanation as to when to use the to + infinitive or to + gerund.
Some more examples:
1) I would like to pass the examination.
2) He isn't used to passing examinations.
3) He really wanted to pass the examination.
Example 2 requires the gerund. The meaning would otherwise be different.
"USED TO PASS" is not the same as "USED TO PASSING".
Below is a link which may help you. Learning when to use the to + infinitive or to + gerund requires a lot of memorization.
verbs followed by gerunds and infinitives
Hope this helps!
Student or Learner