A sunglass strap is the answer.

Get a floating neoprene or cable-style retainer strap. The kind that loops around each arm and hangs behind your head. Costs five to ten bucks.

The waves will rip regular glasses off, and prescription or pricey shades will sink. Neoprene straps float, so even if they come loose, you won’t lose them. If you’re in heavy surf, go one step further: buy a cheap pair of polarized sport sunglasses with a built-in strap (like a pair of goodle-style sunglasses). They stay on through anything.

Don’t try to rely on gripping the earpieces tighter or adjusting the nose pads. Physics isn’t your friend in the ocean. Just strap them on and enjoy the beach.