How to remove all nodes authored by users when their role changes?
You could use the Rules API to define a custom action that gets triggered whenever your users upgrade their accounts. In your custom action you could have a SQL query that searches all that users' content and deletes it.

For how to invoke a Rule programatically see this other DA answer: programmatically-execute-an-action-set-rules-module