What's going on?
When you shake up your warm drink, proteins and fats in the milk act as “surfactants” that trap air bubbles and make foam. There are surfactants in sea water, too, which come from proteins and fats in decaying marine life. When seawater is mixed by wind and waves, air is trapped by the surfactants and sea foam forms.

Infographic transcript
How does sea foam form? Like filling up a bubble bath or steaming a latte, sea foam forms when certain molecules in the water are mixed until they’re frothy. In the ocean, DECAYING MARINE LIFE releases organic molecules, including proteins and fats, into the water. Some proteins and fats can act as SURFACTANTS. Surfactants have a hydrophilic or “water-loving” end that is attracted to water and a hydrophobic or “water-fearing” end that is repelled by water. This dual nature means that these molecules end up collecting on surfaces – the surface of the water, an air bubble, a particle of dirt, or a droplet of oil, for example. Surfactants form spheres called MICELLES with their hydrophilic ends in the water and their hydrophobic ends pointing toward the surface. In the case of sea foam, wind and waves mix the water, and surfactants form micelles around air bubbles, stabilizing them so the bubbles don’t pop right away. This is how sea foam forms.
“Surfactants,” short for “surface active agents,” are found in many places: soaps and detergents, industrial processes, foods, and even our own bodies! Let’s take a closer look at how they work.
One end of a surfactant molecule is polar. This end is called “hydrophilic,” or “water-loving,” because it orients toward water, which is also a polar molecule. The other end of a surfactant molecule is nonpolar. This end is called “hydrophobic,” or “water-fearing,” because it orients away from water.
This dual nature means that these molecules end up collecting on surfaces — the surface of the water, a small particle of dirt, an air bubble, or a droplet of oil, for example.
Surfactants group together around non-polar substances, forming spheres called micelles. When you wash your hands, for example, surfactants in soap form micelles around oil, dirt, and germs, which can then be rinsed away, leaving you with clean hands. In the case of sea foam or a foamy drink, micelles form around air bubbles that get trapped as the liquid is mixed. The micelles stabilize the bubbles and prevent them from popping right away.