Surfactant is secreted by Typ 2 cells of alveolar epithelium although these form on 5% alveolar lining due to small size, they form 60% of cell population lining alveolar epithelium.
Typical lamellar bodies are secreted from the type2 cells. These lamellar bodies are membrane containing organelle containing whorls of phospholipids. These are secreted into the alveolar sac by exocytosis.
Tubular myelin is formed from the lamellar bodies. These are tubular lipids. Phospholipid film is formed from these tubular myelin.
Following secretion, the phospholipids of the surfactant line up in the alveoli with their hydrophobic fatty acid tails facing the alveolar lumen. Surfactants play important roles in reducing surface tension.
Surface tension is inversely proportional to the surfactant concentration per unit area. So on inspiration these molecules move further part hence surface tension increases, but at expiration, they come close hence surface tension decreases.