The Angels are several games out of a playoff spot going into the final week while the Rangers have been eliminated.
Cody (1-1) allowed just three hits and one run in a career-high five innings, striking out five without a walk. He retired 11 straight before Chris Woodward went to the bullpen.
Cody knew he had a five-inning limit, and he punctuated his strikeout of Andrelton Simmons to end the fifth with a fist pump.
"I'm not a huge fan of showing emotions and all the antics, but it's been a long time since I've gone five innings," Cody said. "It's been two, three years since I've gone that long and to be able to go and continue to execute pitches and give my team a chance to win, that felt really good in that moment."
The 26-year-old rookie exited with a 1.53 ERA in seven big league games, including four starts.
Julio Teheran (0-4) was chased in the second inning for the second consecutive game.
Gallo hit a two-run homer off Teheran in the first and Tejada had a leadoff drive in the second. Teheran has given up 12 home runs in 30 1/3 innings this season.
Huff, the 22-year-old catching prospect who made his big league debut earlier this month, hit his first career home run, a shot in the fourth to left-center field off a rock in the water fountain.
It was a banner day for the batterymates who were both drafted in 2016. And it took Huff a while to even realize he'd hit a 410-foot home run.
"I looked up and recognized I did it," Huff said. "It got on me quick. It was fun. I was rounding second base and it didn't really hit me before that."
He said he'll give his first home run ball to his father.
Patrick Sandoval pitched 4 1/3 innings of solid relief for the Angels, with his only blemish the homer to Huff. He kept the Angels close but Odor and Dietrich homered off reliever Ty Buttrey in the eighth.
With the Angels in a must-win situation to have a shot at the postseason, Maddon pulled Teheran after he allowed three runs on two home runs and faced just seven betters.
"Everything's a little bit off. There's no deception in the zone right now for him, which he'll eventually get back," Maddon said. "But for right now under the shortened conditions, the fact that, like I said, had a late start, all these things are contributing factors. But I talked to him about it. I let him know it was something I had to do. He understood. He understood it was about the team first. But it wasn't going to get any better and that's why I did what I did."
Rangers: INF Ronald Guzman left the game with tightness in his right hamstring after he tried to run out a grounder to first.
Angels: INF Franklin Barreto will have shoulder surgery this week, according to Maddon ... OF Upton, who was hit in the helmet on Friday and left the game, was back in Sunday's lineup.
Rangers: RHP Kyle Gibson (2-5, 5.18) is coming off one of the best starts of his career, throwing a complete game shutout in Texas' 1-0 win over Houston. He struck out nine and allowed just four hits in the win.
Angels: RHP Dylan Bundy (5-3, 3.12) is 4-1 with a 2.61 ERA in eight career appearances against the Rangers. He ranks sixth among American League pitchers with a 1.01 WHIP.
The Rangers acquired minor league RHP Stephen Villines from the Mets to complete the Aug. 5 trade that sent RHP Ariel Jurado to New York.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
Jeff Passan debuts the song of the 2020 playoffs: 'Arozarena'
Jeff Passan rewrites the '90s hit "Macarena" centered on Rays breakout star Randy Arozarena.
World Series 2020: What Tampa Bay Rays, Los Angeles Dodgers need to do from here
After a day off before the final game -- or games -- we map out the path to victory for both teams.
World Series Daily: Los Angeles Dodgers eye first title in 32 years as Tampa Bay Rays try to force Game 7
Tampa Bay sends Blake Snell to the hill Tuesday night, while L.A. counters with a bullpen game. Will the Commissioner's Trophy make an appearance?
World Series 2020: Our impressions from inside Globe Life Field
Our reporters have been covering the Fall Classic from inside MLB's newest ballpark. Here's what they say about a stadium few have seen in person.
What makes the Dodgers lineup so strong?
Buster Olney breaks down what makes the Dodgers a strong offensive force and why he expects manager Dave Roberts will aggressively try to clinch the World Series in Game 6.
Doug Mathis, Brendan Sagara to share pitching coach duties for Rangers
The Texas Rangers plan to utilize Doug Mathis and Brendan Sagara as co-pitching coaches in 2021.