* TSX ends down 0.1% at 21,554.86

* For the week, the index loses 0.4%

* Materials group falls 1.3% as metal prices decline

* Energy sector ends 1.4% lower

June 21 (Reuters) - Canada's resource heavy main stock index ended lower on Friday, extending its weekly loss, as declines for commodity prices weighed on energy and metal mining shares.

The S&P/TSX composite index ended down 26.49 points, or 0.1%, at 21,554.86. For the week, the index was down 0.4%.

It was the fifth straight weekly decline for the index, which is the longest such stretch since May 2023.

"This is the momentum of everything going to the U.S.," said Paul Gardner, a portfolio manager at Avenue Investment Management. "With the relative weakness of oil and the commodity space, the TSX has given back some (gains)."

The Toronto market has advanced 2.9% this year, much less than the 14.6% gain for U.S. benchmark the S&P 500, which has greater exposure to high-flying technology shares.

The materials group, which includes metal miners and fertilizer companies fell 1.3% as gold and copper prices declined.

Concern over surplus supplies and sluggish demand in leading metals consumer China weighed on copper prices, which have pulled back from a record peak last month.

Energy also lost ground, falling 1.4%, as the price of oil settled 0.7% lower at $80.73 a barrel.

Combined, the energy and materials sectors account for 32% of the TSX's weighting.

"The world doesn't want to know about Canada ... We think it's pretty reasonable to be exposed to Canadian assets because they trade far cheaper," Gardner said.

The TSX's 12-month forward price-earnings ratio, a key measure of valuation, has fallen to 13.9 this month from 14.7 in March, LSEG Datastream data shows.

Among the sectors that gained ground was technology . It rose 1.1% and consumer staples added 0.5%. (Reporting by Fergal Smith in Toronto and Nikhil Sharma in Bengaluru; Editing by Shreya Biswas and Josie Kao)