Shea took a pass from team-mate Landon Donovan then raced towards the goal where he beat Costa Rica goalkeeper Patrick Pemberton with a precision shot in the 82nd minute.
Neither team failed to create a lot of scoring chances in the opening half.
Donovan had one of the best chances for the USA 12 minutes after the interval when he collected the ball inside the box but failed to make good contact on his shot.
Carlos Johnson almost got Costa Rica on the board in the 78th minute with a nice header off a free-kick but the ball was knocked down by American goalkeeper Sean Johnson.
Celso Borges had another chance for Costa Rica in stoppage time, getting his head on a ball but Johnson made the save.
Needing to score four goals to surpass Martinique as the second ranked third-place team, Cuba did so in the final moments of the match - three minutes into added time - clinching its second quarter-finals berth. Liban Perez headed a cross from the right wing to Marquez Molina, who gently guided a right-footed shot into the net.
As a result, the Lions of the Caribbean will meet Panama on Saturday at the Georgia Dome in Atlanta. Their only previous last-eight appearance was in 2003 and resulted in a 5-0 defeat against USA.
“It was like winning the World Cup,” Martinez said. “It was a great achievement for us and made me very happy. It was a great game for us. We put in as much effort as we needed to. It was a tremendous result.”
Cuba took a 1-0 lead in the 38th minute. Martinez made a diagonal run along the 18-yard box before hammering a shot from 22 metres inside the far post.
The 27-year-old forward added his second in the 63rd minute, finishing a long run with a blast from eight metres to give Cuba a 2-0 lead.
Three minutes after Ian Gaynair was sent off for his second bookable offense, Martinez netted his third in the 84th minute, taking a pass from Alberto Gomez and slotting it past Belizean goalkeeper Woodrow West.
Cuba pressured Belize from the outset, but West was up to the task. In the 14th minute, he saved Jaine Valencia’s shot from distance, while Molina flicked Valencia’s free-kick off the crossbar one minute later.
Belize had a pair of opportunities midway through the first half. Deon McCaulay rolled a shot from the edge of the penalty area into Cuban goalkeeper Odelin Molina's arms on 16 minutes, and Michael Salazar’s effort shortly afterwards went wide.
West continued to play well for the Central American side, denying Martinez on multiple occasions before and after the break.