This is old problem for mostly drupal newbies but I see its not explained properly what should be best practice.
So to do this properly you should
$chmod 775 -R /~/public_html/sites/default/files
so your files directory and all the files inside have 775 permissions. This means they all owner and group have full permissions and public has read and execute but not write.
But this is not all, for drupal to not show you that error, we need to have proper group settings on those files. If having apache as server write
ps aux | egrep '(apache|httpd)'
to get what apache is running as, so you can add this as group to files directory, for example it should be www-data on Ubuntu and Debian. So you would run this command
chown your_user:www-data -R /~/public_html/sites/default/files
to get the group ownership of files as the one apache is belonging to, so then apache has both read/write permissions and it will enable your files to work with drupal.