On the packaging. For boxed software, the product key is printed on the back or inside of the CD case, usually on a sticker with a long alphanumeric string.
For digital purchases, the key lives in your account's order history or confirmation email. If you have lost a physical key, the manufacturer's support line can often recover it with proof of purchase.
Sites advertising "free keys" are selling stolen or generated codes, and using one risks both malware and a deactivated copy.