The Plugin API has hooks for that:
You can use register_deactivation_hook
to run a function when the plugin is deactivated.
For uninstall, you have two options. Either register_uninstall_hook
or add a file called uninstall.php
in your plugin folder.
I would not recommend delete plugin options on plugin deactivation though, the user might not know that he is losing his saved data.