Both are correct but the meaning is slightly different. The first one means in general, the teacher will be angry with you IF you forget to do your homework, that is the action has not been completed yet. The "had forgotten" is the past participle case which means that the action is completed.