Both are leavening agents - and which one you use depends on the acidity of the contents in the recipe. They do the same thing as yeast (produces carbon-dioxide - CO2 - bubbles) but much quicker .... which is why they are used in "quick breads" and cookies, etc., that don't need long proofing periods.
The 25-cent answer ... baking soda reacts immediately with the acids in the recips (like buttermilk or molasses) and baking powder is a mixture of baking soda plus acidic salts that will create CO2 bubbles when they become wet and are heated.
The Cook's Thesaurus
website has a good explanation on leavening agents
you might like to check out for a more indepth explanation.
EDIT NOTE: I spent too long typing ... I like the site Aurora gave ... better explanation than what I found.