In the roots of the plant, oxygen is taken in for respiration, which happens in Mitochondria. It helps render the energy for active transport in the uptake of nutrient from the soil. In the foliage, carbon dioxide is taken in for the process of photosynthesis.
The carbon dioxide is chemically bonded with hydrogen from the splitting of a water molecule to form carbohydrates. In the splitting of the water molecule, the oxygen atoms are combined in a molecule and respired out of the plant.