It will be a first coaching job for Mascherano, who won more than 100 caps for the national side playing in defence and midfield.
The 37-year-old will replace the current coach Fernando Batista from January, the AFA said in a statement.
Javier Mascherano has agreed a deal to take over as coach of Argentina Under 20s next year
The tough midfielder proved a hit with Liverpool fans during his three-year spell on Merseyside
After a long career with stints at River Plate, Corinthians, West Ham and Estudiantes, Mascherano retired in November 2020.
He began his career in Argentina with River Plate, coming through their academy, before his first move to England in the summer of 2006 with West Ham.
In the months that followed his arrival, much confusion – relating to third-party ownership – ensued and he only stayed at the Hammers until the January window, before moving on to Liverpool.
It was there that he established himself, making 139 appearances for the Reds as they finished runners-up in the Champions League in 2006-07.
It is at Barcelona that he is most-fondly remembered though, making 334 appearances between 2010 and 2018.
Alan Pardew welcomes Carlos Tevez and Javier Mascherano to West Ham in September 2006
He had the most successful period of his career at Barcelona with the likes of Lionel Messi (left)