You'll need the code in hand first, then head to Account Manager on the PlayStation Store.
Look for the Redeem Codes option, enter the code exactly as printed, and confirm. The content attaches to your account and downloads from your library.
Two common snags: codes are usually region-locked, so a code bought abroad may be rejected by your account's region, and dashes are sometimes required or sometimes not depending on the code format. If it fails, try both before assuming it's expired.