Why was the TARDIS heavily damaged when the Tenth Doctor regenerated, but when the Ninth Doctor regenerated, there was no visible effect?
Is it a writing error, or just done for plot-based reasons?
The Tenth Doctor's regeneration was an unusually violent one.
It's established that Time Lords have some control over their regenerations. For example, in the classic episode Destiny of the Daleks, Romana (a Time Lady and the Doctor’s companions) regenerated about half a dozen times until she found an appearance that she liked.
In this instance, the Tenth Doctor was reluctant to regenerate. When describing regeneration, he said:
Even if I change, it feels like dying. Everything I am dies. Some new man goes sauntering away… and I'm dead.
He spent a long time putting it off, both before and after his lethal dose of radiation. Once he gets the dose, he makes a final trip to visit many of his companions, trying to keep regeneration at bay.
All that time, regeneration energy is building up. When he finally concedes, it bursts out of him in a particularly explosive way. Normally the Doctor regenerates shortly after his “death”, so there's less of a buildup.
The reason is Tenth doctor "didn't want to go". Due to him forcibly regenerating to save his life, the impact of the regeneration caused mass destruction, flames and violence. Normal, happy regenerations such as the Eleventh Doctor to the Twelfth Doctor (in which he bursts into flames and turns into the twelfth Doctor as quick as a flash) did not cause any trouble for the TARDIS because the Doctor did want to regenerate. As we know, the TARDIS Matrix feels affection for the Doctor before he even knows about her so surely him being so sad and angry would have damaged the Tardis anyway.
It's because of the serious amount of damage his body took probably (he fell through the skylight from hundreds and hundreds of feet, and got cut up pretty badly. And then there's the whole absorbing thousands of radiation energy into himself). Thanks to all the damage, his body needed to heal a hell of a lot of it, and he was dying. I think maybe why the regenerative energy was so explosive, was because all the punishment he took was having a massive strain on his body, slowly killing him while his regeneration built up for hours on end. When he finally regenerated, the energy was so intense, because he needed to heal the immense trauma and poison his body took, and he nearly risked dying, because he held off the regeneration for far too long.