The Brazilian scored the opening goal of the game towards the end of the first half and added the second three minutes into the second period, but was substituted before the end after injuring his ankle, leaving the pitch in visible pain.
The opening half an hour was a cagey affair, with neither team taking the initiative.
Masoud nearly gave the Navarrans an early the lead from a free-kick but saw his effort go just over the bar, and the Iran international later sent the ball into the stands as he tried to convert a clearance from Cata Diaz.
Atletico broke the deadlock on 35 minutes through a counter-attack goal. A wonderful through-ball from Gabi found Koke on the right-hand side and the midfielder raced down the wing and into the box to pass to Costa.
The Brazilian's first effort was saved by Osasuna goalkeeper Andres Fernandez, but the rebound fell at the perfect height for the forward to nod into an empty net.
Costa, whose every touch had been booed by the home crowd, celebrated wildly at giving his side the lead with the first chance they had created.
Jose Luis Mendilibar's side almost responded immediately and were only denied an equaliser by Atleti goalkeeper Thibaut Courtois, who kept out a header from Oier.
The Belgium goalkeeper then had to make a double save right on the stroke of half-time to deny Oier once again.
Diego Simeone's side doubled their lead just after the re-start.
Koke's free-kick sailed into the six-yard box and Costa was waiting at the far post to stab the ball in as it bounced in front of him.
However, Osasuna full-back Damia Abella should really have prevented the goal, but watched passively as the ball came in, allowing Costa to get in front of him and reach the ball first.
The goalscorer had to be attended by the team physio shortly after the goal but continued playing despite hobbling at first. He later did leave the pitch with 17 minutes remaining, complaining of pain in his ankle after he had scuffed a chance to score a hat-trick and injured himself in the process.
Atletico were an improved outfit in the second period and it was up to Andres Fernandez to keep the score dignified, saving from Koke, Radamel Falcao and Cristian Cebolla Rodriguez.
The hosts' earlier determination subsided as the clock ran down, although Courtois had to be alert to stop a stinger from Marc Bertran with five minutes remaining.
The result was the response Atletico would have hoped for after losing to Real Sociedad last weekend and surrendering their 100 per cent home record in the La Liga this season, but Osasuna still face a nerve-wracking end to the season, sitting just four points above the relegation zone.