How to implement a reputation based system with badges in Drupal similar to StackExchange sites?
There's the User Points module and the User Badges module, though the 7.x version of User Badges is not suitable for production yet (as of June 4, 2012).

Thankfully, User Points integrates with the Rules module, which allows you to greatly customize the ways users gain (or possibly lose) points.

There's also a collection of contributed modules for userpoints of varying stability.  You can certainly set up some amazing stuff with these modules, but make sure to carefully test your implementation-- though the modules are well written and fairly stable, there's still a lot that can go wrong so make sure to verify everything works properly.