The goal was Donovan's career-high 20th of the season. FC Dallas' Kenny Cooper finished second with 18.
"I really wanted to get to 20 goals," Donovan said. "Not many people do it, here or anywhere in the world. For me, it's a massive honor. I'm very proud of it -- very, very proud."
Both Los Angeles and FC Dallas will miss the playoffs.
Edson Buddle also scored for the Galaxy (8-13-9), and David Beckham had an assist in his first appearance in two games after playing for England in World Cup qualifying and serving a disciplinary suspension.
Beckham played despite injuring his quadriceps in training earlier in the week.
"I've had it for three days and I haven't been able to train the last two days," Beckham said. "I had a lot of work on it -- a lot of massages, a lot of cold and hot baths."
Donovan praised Beckham's performance.
"I thought David was fantastic," Donovan said. "He really wasn't the best all week and it probably would have been easy for him to take it easy. If he plays like that, we have a good chance to be good in the future."
Drew Moor and Victor Sikora scored for Dallas (8-10-12), which closed the season with a four-game losing streak.
Donovan converted his penalty kick inside the right post after Dallas goalkeeper Dario Sala fouled Eddie Lewis in the penalty area in the 78th minute.
Buddle gave the Galaxy a 1-0 lead in the 21st minute with his career-best 15th goal. Beckham sent a crossing pass from the right flank to Buddle, who scored from five yards out.
Moor and Sikora scored in a 4-minute span to put Dallas ahead 2-1. After Galaxy goalkeeper Josh Wicks deflected Sikora's corner kick, Moor redirected teammate Adrian Serioux's weak shot in the 34th minute.
Sikora scored his first MLS goal in the 38th minute. Duilio Davino's long pass freed Sikora on a breakaway, and Sikora made a 16-yard shot.
FC Dallas' Bobby Rhine and the Galaxy's Greg Vanney played their final professional games after announcing they will retire.
The Galaxy set team marks this season for fewest victories (8) and most goals allowed (62).