The most likely explanation is an exciting dream, in which case the rapid breathing will come to its natural end as the dog's sleep cycle changes.
Panting due to oxygen deprivation may also occur in dogs with anemia, which limits the number of red blood cells that carry oxygen to the body.