It is recommended that it should be done atleast one in a week.
1. Login to cPanel
2. Click on the phpMyAdmin button in the Databases section.
3. Select the database you want to optimize and repair from the list in the left column, which should take you to the "structure" tab for the database.
4. Select the tables you wish to optimize by checking the check box in front of each one, or clicking on Select All if you want to optimize all of them.
5. On the drop down box that says "with selected..." select "Repair Table." This will repair the table and take you to a new screen.