MacPhee, 45, is one of the most experienced and respected set piece coaches in the game and will combine his duties at Villa with those with Portugal.
He was previously on Steve Clarke’s staff with the Scotland national team, but was forced to reduce his workload last September because of his father’s health.
MacPhee will start working with Martinez in March when Portugal face Denmark in the quarter-finals of the Nations League.
As a player, the Scot turned out for teams in the United States, Romania and Japan. He moved into coaching in his late twenties and was Assistant with St Mirren, Hearts, Mexico, Northern Ireland and FC Midtjylland before being appointed as Villa’s first Set Piece Coach in August 2021.