I am building my API. When I launch it it in debug mode, it launches with the file:
launchSettings.json. It uses then the correct IP and port to launch.

When I build the API and run the exe file it launches with localhost.

What am I doing wrong?
As far as I know, the lanchsetting,json will just work when you debugging the application in visual studio. It will not affect the exe file.
If you want to run the exe to launch with specific IP address, I suggest you could try to use UseUrls method in the CreateHostBuilder method.
More details, you could refer to this codes:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>().UseUrls("http://172.17.12.63:5000");
});
Result:
LaunchSettings.JSON?