Theme and plug-in settings are stored in the database. Almost all plugins and themes keep all their settings upon deactivating and removal. In fact, removal just simply removes the files.
Plugins like iThemes Security, JetPack and WP Super Cache do partial database pruning because they need to or they will break the installation if they do not remove those modifications upon removal. However, most plugins do not do anything to the database when deactivated.