Overheating is an overused and often erroneous term. When an iPhone truly overheats, it shuts down and displays an image of thermometer, with a notification that the phone must cool down before it can be used. If you aren't seeing such a warning, the phone is NOT overheating.
Next, when people get a new iPhone, for the first few days, it works hard behind the scenes to index the millions of bytes of data on the phone. At the same time people are often using their phone to watch videos on social media, taking photos/videos, streaming music, etc., which makes the battery work harder. And when a battery is pushed harder, the laws of thermodynamics dictate that the battery will generate heat in the process.
Don't push your phone too hard for the first few days and in almost all cases, it will settle down. But if you are actually seeing a thermal shutdown, with a thermometer on the screen, then schedule an appointment at your Apple Store Genius Bar and have Apple test the phone.