Inter were the better team for the first 45 minutes, but the game was at a goalless stalemate when the referee whistled for halftime.
The visitor's Lautaro Martinez had the real first chance of the game but his half-volley after five minutes went just wide of the post.
Juventus' first chance came after 19 minutes when Gleison Bremer tried a volley from Kostic's cross but the effort went wide.
Edin Dzeko was close to putting Inter ahead after 26 minutes with a header from Martinez's cross, but again the effort went just to the side of the post.
The visitors continued the pressure in the first minutes of a second half that created opportunities for a Juventus counter-attack.
Kostic took advantage of a cleared Inter corner and raced into the box, where Adrien Rabiot guided the assist elegantly into the lower right corner in the 52nd minute.
Juventus could have doubled the lead after 63 minutes but Danilo's goal from a set piece was revoked after a VAR decision due to a handball.
Kostic then fed an unmarked Nicolo Fagioli on the other side of the box six minutes before full-time for the second goal.
"It was great to watch this game, especially as we were a little lucky in the first half, but when you have a proactive attitude and work for your teammate, you are more likely to get a positive result," Juventus coach Massimiliano Allegri told DAZN.
"The system has given the team more solidity, but the most important thing is that the team works together, defends behind the ball, understands when it's time to suffer and that it lasts 95 minutes.
"Earlier in the season, we would play about 30 minutes and then drift off, but we are in it all the way now, even during tough moments. That is an important step."
Juventus are fifth on 25 points, level with Roma in sixth and 10 behind leaders Napoli. Inter are seventh on 24 points.