Overheating can be caused by a few things.
If there's a short in the battery, you have to replace the battery. (If it's a dendritic short - it goes away for a while, then comes back - it's a manufacturing defect, so they SHOULD replace it. But don't bet on it.)
If the charging circuit in the phone goes bat it can overheat the battery. Then any battery you charge in the phone will overheat.
If the phone was in a place where it dodn't get any airflow (like under your blanket in bed), it will overheat, but not charging it like that will fix the problem.
There are other possibilities. Without testing things, there's no way to tell for sure why your battery overheated.