Keane, who has 12 goals this season, sent Donovan alone into San Jose's box to give Los Angeles a lead in the 26th minute. Keane then converted a penalty kick in the 43rd and scored on a volley in the 67th.
Donovan, playing his final game with the Galaxy before joining the U.S. national team for two World Cup qualifiers, scored his eighth goal of the campaign and moved within two goals of MLS career leader Jeff Cunningham's total and one behind Jaime Moreno's.
The Galaxy (13-9-4) have won three straight league games for the first time this season to strengthen their hold on second place in the Western Conference, five points behind Real Salt Lake. San Jose (9-10-7) is in eighth, five points out of a playoff berth.
The Earthquakes rallied from two-goal deficits to beat Los Angeles in three of their past four regular-season meetings, including July 29 at Stanford University, but they struggled to broach the Galaxy's defense, which posted its third successive shutout in all competitions.
"We're playing well and are full of confidence," said Donovan, who has 12 goals in his last 12 games, including those with the national team. "Everything's clicking, and I think we felt when we had our full team together, this was possible. So we're real happy with how things are going, and we want to keep making a push and try to catch San Jose."
Los Angeles went ahead after Omar Gonzalez headed away a San Jose free kick into the Los Angeles box, Marcelo Sarvas fed Keane at midfield, and the Irish forward lifted the ball over the Earthquakes' backline as Donovan ran into open space. Donovan pushed the ball past goalkeeper Jon Busch and rolled the ball into an open net from a tight angle on the right.
Keane made it 2-0 after Steven Beitashour fouled Gyasi Zardes and netted the third from a Zardes cross that Sean Franklin headed back to him. He nearly scored on four other occasions, the best a shot across the goalmouth and past the right post in the 68th minute and a 1-on-1 blast that Busch parried 10 minutes later.
"We know that they're a very dangerous team," San Jose coach Mark Watson said. "When they're on form, they're the best team in the league. If we give them time and space, they were going to hurt us. ... If you give Landon Donovan and Robbie Keane time and space to run at you, you're in big trouble."
Keane has seven goals and three assists and Donovan five goals and three assists and in Los Angeles' last five games, including a CONCACAF Champions League win over Costa Rica's Cartagines 1½ weeks ago.