Derby controlled the game for long periods of the first half and Richard Keogh's close-range header almost gave the visitors an early lead.
County continued to look the more likely of the two sides to open the scoring, with Jack Robinson only a couple of inches from the target with a 25-yard strike.
However, it was Peterborough who made the breakthrough before the break when Bostwick fired his volley past the outstretched hand of Adam Legzdins.
George Boyd gave the hosts the chance to double their lead after the break by winning a penalty following a challenge from Keogh.
Lee Tomlin stepped up from 12 yards but Legzdins reacted superbly to push the ball around the post.
Peterborough were not unsettled by the penalty miss and Boyd went close to scoring with a powerful drive that flew over the crossbar following a smart turn inside the penalty area.
Derby's hopes of claiming a point were dealt a blow when Jake Buxton was dismissed for two yellow cards in the space of six minutes.
The home side finished the better of the two sides and despite Legzdins denying Bostwick a second goal, the Derby keeper failed to keep out Berahino's long-range effort just moments later.
Berahino added his third in stoppage time by calmly slotting past an advancing Legzdins.