There could be quite few reasons why Samsung Galaxy S4 is overheating.
1. It could be just a software problem. Check the updates if any released. If yes update the software.
2. Another reason could be an installed program which is causing this problem. Check for program updates if any released or try to uninstall it.
3. Backup all your data on your computer. Now remove the SD Card. Format the micro SD Card. This may help you to solve the problem.
After trying all the above solutions, if your Galaxy S4 is still heating up, then it’s time to contact your retailer or Samsung to report the problem. You can possibly get a replacement phone. Good luck.