Costa netted his sixth goal in 12 appearances since moving back to the Spanish side from Chelsea in January.
Saul Niguez and Koke were also on target for the 2010 and 2012 winners.
Lokomotiv are seven points clear at the top of the Russian Premier League, but now face a substantial deficit going into next week’s return leg.
“In the whole game we were superior,” Atletico coach Diego Simeone said.
The home side opened the scoring midway through the first half courtesy of Niguez’s superb strike from 30 yards that sailed into the top corner.
Costa added Atletico’s second at the start of the second half by steering home the rebound after Antoine Griezmann’s shot had been saved.
Griezmann and Costa were both withdrawn as the half progressed, but there was still time for Koke to burst into the area and find the corner.
“In no way did I feel embarrassment for the team,” said Lokomotiv coach Yuri Semin. “We do not consider the tie lost.”
Salzburg shock Dortmund
Kosovo international Valon Berisha scored twice as Red Bull Salzburg won their first leg 2-1 against Borussia Dortmund in Germany.
Berisha was on target twice shortly after half-time before Andre Schurrle’s strike reduced the deficit going into next week’s return game in Austria.
Brazilian defender Marcelo scored the only goal as last season’s semi-finalists Lyon grabbed a 1-0 win at CSKA Moscow.
Valon Berisha opened the scoring for Red Bull Salzburg from the penalty spot
Henrikh Mkhitaryan and Aaron Ramsey scored in the first half as Arsenal beat AC Milan 2-0 at the San Siro.
In the later kick-offs, Lucas Ocampos scored twice with Dimitri Payet also on the scoresheet as Marseille saw off Athletic Bilbao 3-1.
Sporting Lisbon put one foot into the quarter-finals with a 2-0 home victory against Viktoria Plzen.
Lazio were held to a 2-2 draw at home by Dynamo Kiev, while Timo Werner ended a four-game goal drought as RB Leipzig recorded a 2-1 win over Zenit St Petersburg.