By default, if it's a retail code, or a code you purchased from other authorized platforms, you need to go to the redeem page.
Once there, just input the code, click the checkbox next to "I'm not a robot", and click "continue". If all goes well, the game info will be displayed, and the game(s) will be added to your account once you click "continue" again. Keep in mind that the code will be "reserved" for you for a few minutes after it gets "opened". To make it redeemable by others, click "cancel".
If your code doesn't work, double-check in case you made a mistake when typing it in.
If you purchased the code from an unauthorized "key reseller", it's possible that the code was either blocked, or used by someone else before you.
If you want to redeem a game which you purchased outside of GOG, please consult the support article below.