A captain of the Pakistan Army was among the dead.Thirteen people were injured in the blast in Swat district's Kabal Tehsil.
The bomb exploded on Saturday evening when the soldiers were playing volleyball after duty in the unit's sports area.
Security forces have cordoned off the area and are searching for possible accomplices of the bomber.
Talibanmilitants were pushed out of Swat Valley after the Pakistani military launched an offensive against militants in the region.
In a statement sent to media, the extremist group said a lone suicide bomber carried out the attack to avenge the killing and arrests of fellow militants.
At least two militants were killed during a search operation in December a year ago. However, more than 2,000 Taliban insurgents had been ousted in 2009 in a military operation.
Prime Minister Shahid Khaqan Abbasi strongly condemned the suicide attack in Swat.
Prime Minister Abbasi said the war against terrorism will continue till the elimination of the last terrorist from Pakistan.
Since then peace has returned to the area popular with domestic and foreign tourists, and militant attacks have become extremely rare in the valley known as Pakistan's Switzerland. Earlier the Pakistani Taliban militants had a strong influence in most parts of Swat.
EBay will switch to Adyen payments platform from PayPal
The announcement surprised some investors, who expected the companies to announce an extension to their operating agreement. This is in spite of PayPal's CEO Dan Schulman telling analysts that their changing relationship with eBay was "manageable".
Total lunar eclipse happening early Wednesday morning
A lunar eclipse is when the sun, Earth, and moon form a straight line - with the moon passing through the shadow of the Earth. When the entire disc of the moon crosses the darker shadow, the eclipse is known as a total lunar eclipse .
Elon Musk Has Made $3.5 Million Selling Flamethrowers
The Boring Company admits this is overpriced, but it comes with a cool sticker and "the button is conveniently riiight above". The Ohio-based company Ion Productions launched an Indiegogo campaign in support of its XM42 flamethrower in 2015.
Harley Davidson to close Kansas City plant
The Palisade Capital Management Llc holds 1.25 million shares with $23.43M value, up from 1.23 million last quarter. Harley-Davidson's retail motorcycle sales were off sharply in the company's latest quarterly earnings report.
Cleveland Browns: Impacts of the Alex Smith trade
The Redskins, with Robert Griffin III on the roster and with uncertainty over Cousins' future, wanted to wait. Cousins told USA Today he spoke to owner Dan Snyder and coach Jay Gruden, but not team president Bruce Allen.
Transfer window to open on June 9
This probably prompted each of them to make at least one key addition to their squads before the deadline shut on 31st January. Liverpool got in early to line up the costliest deal of the month, signing Virgil van Dijk from Southampton for £75m.