With a burglar who has unlawfully trespassed into your home it will be fine. Outside, on your property, within a fenced yard, it gets more questionable but still generally fine, especially if they are not a deliveryman or meter reader and are at least 18 years of age and have no lawful reason to be there.

Dogs generally get put down for running loose in the neighborhood biting random people.