I have disabled the 'mollom' module a long time ago but the tables ('mollom' and 'mollom_form') still exit in database and it takes time to repair them when I try to optimize the database. So I am wondering whether it is safe to remove these tables altogether?
Disabling a module doesn't mean uninstalling it. To uninstall a module, once you disabled it, you need to go to admin/build/modules/uninstall (Drupal 6), or admin/modules/uninstall (Drupal 7, and Drupal 8), select one of the module listed, and click on the button to uninstall them.
Since Drupal 7, every database table declared with hook_schema() is automatically deleted from Drupal. Modules still need to delete any Drupal variables they define, though. Since Drupal 8, a module can just be uninstalled. You cannot anymore first disable it, and then uninstall; you just go to admin/modules/uninstall and uninstall the modules you need. If the module cannot be uninstalled for any reason, Drupal will show in that page the reason why it cannot be uninstalled.
If you uninstall the module, it should take care of this for you. By implementing
hook_uninstall() modules can define the actions to clean up when the module is not needed anymore, e.g. removing database tables, variables etc. If you only disable the module, these actions will not be performed, so you won't loose the configuration when you enable the module again. You have to uninstall it, when you don't need any of its data.
You can go to admin/modules/uninstall, see the list of the disabled modules and uninstall them.
If you use drush, check out the