A gift code can be purchased by selecting the "Select to gift this order" option, during checkout. You can either send it directly to the recipient, in a GOG-made e-mail, or send it to yourself, and then forward or PM it to someone. The gift recipient will be able to choose which items from the gift they want to add to their account. By default, if the gift recipient already owns some of the items within the gift, these will remain in that gift, and can later on be redeemed by someone else.
To redeem a gift code, go here.