The Real Madrid winger curled a low shot past Diego Benaglio after Lionel Messi's run and pass to see off a spirited challenge from Ottmar Hitzfeld's side
Not for the first time this tournament, Alejandro Sabella's men struggled to make their presence felt in attack for large spells, with the Real Madrid midfielder guilty of conceding possession on a number of occasions.
However, Di Maria popped up with just two minutes of extra-time remaining to sweep home after some good work by Lionel Messi.
Substitute Blerim Dzemaili headed against the post for Switzerland before time was up, and should have done better with the rebound.
The result sets up a last-eight meeting for Argentina with Belgium or the United States in Brasilia, and was ultimately harsh on a Switzerland side who defended resolutely in what will now prove to have been Ottmar Hitzfeld's final game in charge before retiring.
Argentina were forced into one change, with Ezequiel Lavezzi coming in for injured striker Sergio Aguero, while Switzerland stuck with the same XI that triumphed 3-0 over Honduras in their closing Group E fixture.
Xherdan Shaqiri ran riot with three goals in that convincing victory, but chances were few and far between for both sides in the opening stages in Sao Paulo - a Gonzalo Higuain header that comfortably cleared the crossbar was as close as either came to hitting the target inside the first 25 minutes.
Switzerland injected some life into an otherwise dormant half in the 28th minute when Granit Xhaka and Stephan Lichsteiner were both denied by Sergio Romero in the Argentina goal, before Lavezzi called Diego Benaglio into action at the other end with his team's first accurate effort moments later.
Germany's Manuel Neuer produced a superb goalkeeping display in their last-16 clash on Monday, effectively acting as sweeper at times when his defence was breached by Algeria, but Argentine counterpart Romero was statuesque when Josip Drmic found himself clean through on goal in the 39th minute.
Romero was far from convincing in keeping out a Shaqiri free-kick from 25 yards five minutes into the second half, and Argentina looked short of ideas going forward, evoking memories of their last-gasp 1-0 victory over Iran in the group stage.
Benaglio denied Marcos Rojo from a tight angle as Argentina got a rare sight of goal, before Di Maria attempted a flamboyant cross.
Trying to be pleasing on the eye, he left his team-mates far from pleased as his showboating resulted in a Swiss goal-kick and an opportunity wasted.
Benaglio's reflexes were put to the test shortly after the hour mark as he tipped over from a powerful Higuain header, and Messi shot narrowly over soon after as the Argentinian pressure started to build.
Messi went close again with a drilled effort that Benaglio got down well to meet, but both nets remained untroubled as a last-16 clash entered extra-time for the fourth time this tournament.
Having disappointed for much of the game, Di Maria ultimately emerged as the hero for Argentina.
The 26-year-old, who had earlier forced Benaglio into a fine save at his near post in the second half of extra-time, received the ball following a probing run from Messi and calmly slotted a left-footed finish across Benaglio and into the far corner.
Dzemaili remarkably had a chance to equalise in injury time, but headed against the post from close range before failing to convert the rebound.