Modal verbs are a very tricky thing to explain! Seeing as how nobody else wanted to touch this question, I'm not the only one who thinks so. The only way I can think to explain why the above sentence is correct is by giving examples of why it would it wrong in the past tense.
I'll start by saying that when "must/must not" is used as an advisory or recommendation for or against doing something like in the above sentence, AmE strongly favors using "should/shouldn't." So we would be more likely to say "He knew he shouldn't give in to temptation."
The past tense use of must (not) -- must (not) have + past participle -- loses the meaning of recommendation and expresses your certainty of an event without having been directly told. For example:
*If you say "Tom must have woken up late today" - nobody told you that Tom woke up late, but you think that he did because of certain clues, like Tom didn't have time to brush his hair before class, he didn't show up on time, etc.
*If you say "Mom must not have gone grocery shopping this morning" - Mom never told you that she didn't go grocery shopping, but you're certain that she didn't because there's no food in the house.
So to use the past tense of "must not" in the above sentence doesn't carry the same meaning - the past tense of must always shows your certainty, it's unrelated to the present tense meaning of strong recommendation. If the sentence were "He knew he must not have given in to temptation," it would make American speakers wonder what you're trying to say.
If we use the word "should" in place of the word "must" we can also see a difference in meaning if it were used in the past tense.
should (not) have + past participle means that it would have been better if something happened differently than the way it actually did. For example:
*If you say "I shouldn't have gone to bed so late last night" it means you regret that you didn't go to sleep earlier than you actually did (because you're tired today, you were late to school, etc).
*If you say "I should have gone to see that movie" it means that you didn't go see that movie and now you regret it (because you heard it's a great movie, it's not playing at the theater anymore, etc)
So if you used the above sentence to say "he knew he should not have given in to temptation" it means that he really did give in to temptation, and he now regrets that he did. It still has the meaning of recommendation, but it applies to the opposite of an event that already took place in the past.
The past tense of these modals changes the meaning, the present tense is the only acceptable form to use to express the meaning in your sentence.
I hope this was helpful and not too confusing! I couldn't think of anything more concise than just giving examples.
(not a teacher, just a language lover)