In the process of photosynthesis, plants use carbon dioxide to produce sugars and starches as a way to store energy, and to produce structural materials such as wood. In the process, they give off oxygen as a waste product.
On the other hand, plants use oxygen for respiration, just as animals do. The oxygen is used to chemically tear apart the sugars and starches, releasing the energy, and producing carbon dioxide as a waste product.
Luckily for us, plants give off more oxygen from photosynthesis than they use for respiration.