There are different types of two factor authentication. Some types will protect against the threat you describe, others will not.
Here are some common types of 2FA that will keep you protected against the key logger:
- Texting a one time use code to a mobile phone.
- Emailing a one time use code with the assumption that the user will not check the email on the compromised computer. (Receives the email on a mobile phone.)
- Some sort of token using a time-based mobile app.
Typically the above types of 2FA do not have an option for "remember this computer" which would disable the 2FA portion of the login. If they had a "remember this computer" option, that would drastically reduce security, as you suggested.
There are some weaker types of 2FA that may contain a "remember this computer" option. Typically they would be an additional security question such as what is your favorite food, or mother's maiden name, etc. If there is only one security question, then your answer is going to be recorded by the key logger as well, so the "remember this computer" option is irrelevant. The only situation where the key logger with the ability to silently check the "remember this computer" box would be useful (to the attacker), is when you have multiple security questions set up which are presented on a round robin basis, and only 1 of them is captured by the key logger.
As a side note, if you are worried about key loggers, I suggest when typing in a password on a public computer, that you type in part of it with the keyboard and the rest of it with the mouse and the virtual on-screen keyboard. This will thwart someone watching the screen or a key-logger. Someone would need to have both going at the same time to capture your full password.