The lungs are where the gases in the blood are exchanged. CO2 for O2.. The exchange of gases that occurs in the lungs is done through capillaries, after the blood from the veins is emptied into the heart. Then the heart pumps blood from the veins to the lungs.
The Heart pumps oxygenated blood through the arteries. The veins return the blood to the heart.