Max Gradel put the Cherries ahead with his first goal since his long injury lay-off, before Modou Barrow equalised.
Joshua King rifled the hosts ahead in the second-half before Gylfi Sigurdsson curled in to get the Swans level. But Cook was the match winner for Eddie Howe's men as he superbly headed in Matt Ritchie's cross to secure the Cherries' third win in a row.
The game started in a lively manner, which saw King go close twice in the opening six minutes.
The first chance, after two minutes, came as Gradel showed some trickery on the left-hand side and crossed for the Norweigan who rose above Neil Taylor but nodded over from eight-yards.
King then dragged an effort over from ten-yards as he met Benik Afobe’s flick on in the box.
The Cherries did break the deadlock though after 37 minutes and it was the lively Gradel who capitalised on a stray punch from visiting keeper Lukasz Fabianski.
Adam Smith’s cross from the right was parried by the Swans stopper right into the path of Gradel who hit a sweet finish into the bottom right corner.
The Ivorian wheeled away straight to manager Howe and exchanged an emotional embrace with the Cherries boss.
Chants of ‘we are staying up’ came from the Steve Fletcher Stand but they were short lived when just two minutes later, Barrow cut inside from the right with a blistering turn of pace before smashing a curling effort into the far corner which gave Artur Bouc no chance.
That was the last action of the first-half and Howe brought on Eunan O’Kane for Dan Gosling to start the second-half.
It didn't take long after the restart for the Cherries to capitalise on a positive start to the second-half and they had the second goal just five minutes after the restart. Gradel again capitalised on a Swans error and laid off King just outside the area. The striker took a touch into the box and composed himself before arrowing an unstoppable effort off the near post and in.
But like Gradel before him, Barrow went from scorer to provider as the Swans drew level once again after 62 minutes. Barrow got to the byline on the right and put in a low ball which wasn't cleared, Sigurdsson collected it to calmly curl the visitors level from 10-yards.
Afobe and Gradel then made way for Lewis Grabban and Marc Pugh, but it took a top save from Boruc to keep the Cherries level with 15 minutes to play.
Alberto Paloschi lashed a volley from six-yards which Boruc stood strong and fisted away.
That save proved to be a massive moment as with 12 minutes to go, a short corner helped the Cherries notch the winner.
The set play was worked to Matt Ritchie and the Scotland international swung in a high cross, which saw Cook tower over his man to glance a header into the far corner.
The win moved the Cherries 13 points clear of the drop-zone and now takes the club onto 38 points in the Barclays Premier League table.
AFC Bournemouth: Boruc, Smith, Francis, Cook, Daniels, Ritchie, Gosling (O'Kane 45), Surman, Gradel (Pugh 75), Afobe (Grabban 65), King.
Subs not used: Federici, Elphick, Distin, Iturbe.
Swansea City: Fabianski, Rangel, Fernandez, Williams (c), Taylor, Fer (Sung-Yueng 84), Cork, Sigurdsson, Barrow, Routledge (Gomis 59), Paloschi.
Subs not used: Nordfeldt, Amat, Naughton, Britton, Emnes.
Goals: Gradel (37), King (50), Cook (78). Barrow (39), Sigurdsson (62).
Attendance: 11,179 (1337 away fans)
Referee: R East
Yellow cards: Gosling
Don't miss any of our post match content from a huge win for the Cherries, including Mascot Cam, Pitch Walk, post match interviews and much more on Cherries Player HD