The sanctions exist for two reasons: to directly prevent "enemy" nations from gaining weapons (or economic infrastructure) to use for bad purposes, and to put pressure on the foreign government (directly on members of the government, and indirectly through the population) to provoke change.
Sanctions which are directly targeted against weapons are pretty obvious -- don't sell chemical weapons to middle-eastern dictators with a history of gassing parts of their own population (oops, Iraq and Libya...).
Sanctions which are targeted to dual use technology, e.g. not selling advanced routing and firewall equipment to countries which are engaged in repression and murder of their own populace are more of a grey area (oops, Syria and I believe Libya...); selling to the government directly is generally out, but it's often ok to civilian businesses as long as you're able to document that it's not going to end up in the hands of the government.
General "punishment" economic sanctions are a lot more rare, and even then they generally try to weight them so the leadership is disproportionately affected (I believe the ruling cadre's favorite brands of cognac, etc. are embargoed to North Korea, which wouldn't affect normal people; regular food is not restricted.)