The best place to buy a pet hamster is typically direct from a breeder, as this way you are more likely to find a healthy hamster that has been well treated and therefore has a good temperament. This is less likely if you choose to buy from a pet store.
However, most pet stores will offer a guarantee which will allow you to return your hamster should it be unsatisfactory as a pet or if it becomes sick, in exchange for a refund or a new hamster. They are therefore still a good option if you cannot find a local breeder.
Alternatively, you may want to buy your hamster from a rescue center, which allows you to buy at a cheaper price and support a good cause.