If your dog has just come inside after running or exercising or other exertion then it could be due to that.
It's normal for a dog to start breathing fast and heavily after they get exhausted just like us humans will start breathing faster and harder when we get exhausted.
If your dog isn't exhausted then it could be poisoning or heatstroke if it's hot out.
If your dog suddenly started breathing heavily and there's not a reason that is obvious then you should get your dog to the Vet immediately.