Baking soda is pure sodium bicarbonate. Baking powder on the other hand is a mixture of sodium bicarbonate, an acid salt and an inert substance like corn starch.
Baking powder is used as a leavening agent for baking breads and cakes. When baking powder is added with the other ingredients and placed in the oven, the high temperatures cause the acid salt to break down and the reaction with the sodium bicarbonate releases carbon dioxide. The salt used in the baking powder decides the rate at which carbon dioxide is released and is chosen appropriately to ensure optimum baking.
Baking soda can also be used as a leavening agent if the dish contains acidic ingredients which would break down the sodium bicarbonate and this eliminates the requirement of an acid salt to be added with the bicarbonate. If baking powder were used here, an acidic after taste would be left behind.