Ocho Rios is my least favorite port in the Caribbean. If you want a clean safe beach there, walk off the ship and about 200 hundred yards away is Island Village, a secure open mall with a beach down by Margaritaville (located in the Island Village complex). It is literally right at the pier and you don't need a taxi.
In Cozumel, just go to the taxi stand at the dock and tell them you want to go to Paradise Beach. Paradise has no entry fee but they expect you to buy food and drinks of $10 per person or more (you will anyway). Taxis will be available to bring you back to the ship. Other than a phony little beach (big sandbox really) at "Senor Frogs 1/2" Bar, there are no beaches within walking distance of the piers. The taxi to Paradise only takes a few minutes.