Jelle van Damme had the visitors ahead within three minutes, but Chris Wondolowski ensured that the Quakes entered half-time even after driving a low shot from the edge of the 18-yard box to level the game.
The U.S. international then doubled his tally in the 51st minute, before Danny Hoesen gave the hosts a two-goal buffer just past the hour mark.
Andrew Tarbell's own-goal gave the Galaxy hope five minutes from time, but San Jose held on to the victory to book their place in the next round.
WATCH: San Jose's three goals sink Galaxy
Chris Wondolowski scored a brace for San Jose as they take down the Los Angeles Galaxy in the U.S. Open Cup quarter-finals.