Permissions should be 644 and 755 as explained by Shyam.

The problems you encounter are more likely related to the way your server is set up. Most of the time this happens on shared hosters where Apache runs on a different user than your FTP account. Since you usually upload Joomla using FTP, Apache isn't the owner of the file and thus doesn't have the needed permissions to change it.
There is an FTP mode within Joomla which allows to bypass that problem. You can enable that in the Joomla global configuration. It will then do all file access using the FTP user instead of the regular Apache user.
The better way however is to ask your hoster to fix the issue. They can set up PHP to run with a special user, which in that case should be your FTP user. Then everything will work fine.