Excitement/Anxiety
Sometimes when dogs become excited or anxious they can cough. This is usually seen in dogs with tracheal collapse (where part of their windpipe has begun to collapse) because their heightened state of excitement or anxiety means that they are breathing harder.