First thing first, let's define a bug at the beginning - it is any deviation from expected result. I made it so general for a purpose. We need to remember that bugs are not only related to the software we're developing but also for ex. to a build process, deployment process that we follow, and many others.
When it comes to the bug we have one simple question to ask: is the bug related to current stories (stories we work on in a current sprint)?
- yes - fix it
- no
- solving bug won't jeopardize sprint goal - solve it within the sprint
- solving bug will jeopardize sprint goal - estimate it, add to your backlog and prioritize against other stories
Obviously I'm not talking about production issues as treating these beasts requires a different set of rules, including a simple rule: abandon anything you're doing and put 150% effort into solving the damn bug ;-).