Just like you can create discount codes in the Admin, you can also block them there. Go to Settings → Discount and choose a discount code group, click on 'Discount codes'. Check the codes that should be blocked. Click 'Block'.
To unblock the codes, check the codes to be unblocked again. Now click on the arrow next to 'Block' and click on 'Unblock'.
