An earthquake of magnitude 6.2 struck off the coast in Costa Rica on Saturday with a depth of 18.6 km, the U.S. Geological Survey (USGS) said.