Actually in the book, Griphook just disappeared with the sword (with it coming to Harry and co. later) so we sont know if he survived or not ... and Bogrod was last heard of when Ron and Hermione struggle to keep him from falling under the tide of multiplying gold at the Lestrange Vault.
In the film, Bogrod was scorched to death by the Gringotts dragon while still under the Imperius Curse and Griphook was killed at Malfoy Manor with the other Gringotts goblins and guards by Voldemort for the break-in.
- - - - - - - - - - - -
For Griphook, it seemed necessary because of war happening and also because it was karma for his betraying the trio out of petty spite.
As for Bogrod, due to the fact that he was still under the Imperius Curse and he was burned to death, I don't think he deserved it. And so there was no reason for him to die.