The right wing is third in the league with 21 goals, including 11 that have tied the game or given the Ducks a lead. He had a pair of goals in the first period and completed the first hat trick of his five-year career on an empty-net goal with 49 seconds remaining.
Sonny Milano also scored and Jamie Drysdale had two assists for Anaheim, which snapped a two-game skid. John Gibson stopped 28 shots.
Ducks coach Dallas Eakins earned his 100th NHL win behind the bench.
Cam Atkinson scored Philadelphia's goal and Carter Hart made 29 saves.
The Flyers have dropped two in a row after collecting points in seven straight games. They were without leading scorer Claude Giroux and defenseman Ivan Provorov after they were placed in the NHL's COVID-19 protocols.
Hampus Lindholm fired a shot from the top of the left circle that was tipped in by Terry at 3:21 of the first period. It was originally ruled no goal after the puck hit the near post, but a replay review determined it crossed the goal line.
Six minutes later, Terry got the puck in the neutral zone, put a nifty move on Flyers defenseman Travis Sanheim and flipped in a shot on the breakaway.
Atkinson brought the Flyers to 2-1 with 1:18 remaining in the first on a redirect of Joel Farabee's pass. Atkinson has 13 goals this season, but it was his first since he had a hat trick against New Jersey on Dec. 14.
Milano scored Anaheim's sixth power-play goal in his last six games with 2:11 left in the second period when he took Sam Steel's pass and put it into the short side after Hart was out of position.
Flyers: Begin a three-game homestand Thursday against the Pittsburgh Penguins.
Ducks: Host the Detroit Red Wings on Thursday.