As the lungs branch into smaller and smaller airways, the end in specialized sacs called alveolae. Here, oxygen passes through the lung membranes into the bloodstream, and waste products like carbon dioxide flow out of the blood and into the air, and are subsequently expelled when you breathe out.
Fish also need oxygen to live, but their lungs are not designed to extract oxygen from the air.