The Giants took the lead when Jermaine McGillvary touched down but the visitors fought back through Junior Sa'u's try and six points from O'Brien.
Alex Mellor went over twice for the Giants but O'Brien scored twice himself to keep the visitors in control.
Ukuma Ta'ai slid over for Huddersfield before Josh Jones powered over to secure the win for Salford.
Jones' try was perhaps the most impressive of the night, the former St Helens man getting over the line despite the efforts of six Huddersfield defenders.
Huddersfield will be disappointed not to have added to their opening-day win over Widnes but they came up against a Salford defence in fine form.
The visitors lost 26-16 at home to Wigan in their first game of the season but kept the Warriors out for the whole of the second half and built on that at the John Smith's Stadium.
Chairman Marwan Koukash confirmed to the BBC after the match that half-back Todd Carney, who was granted a visa on Thursday, should be in the country on Sunday.
Huddersfield: Gaskell, McGillvary, Cudjoe, Mellor, Murphy, Brough, Brierley, Ikahihifo, Hinchcliffe, Ta'ai, Lawrence, Ferguson, Rapira.
Replacements: Wakeman, Leeming, Roberts, Clough.
Salford: O'Brien, Johnson, Welham, Sa'u, J. Carney, Lui, Dobson, Kopczak, Tomkins, Mossop, Jones, Griffin, Flanagan.
Replacements: Krasniqi, Tasi, A. Walne, Wood.
Referee: James Child.
Gareth O'Brien scored 22 points to help Salford beat Huddersfield for their first Super League win of the season.