Most of the heat is left over from when the planet formed (from all the impacts; energy of motion converted to heat, plus increase of temperature with pressurization, and some chemical energy as things reacted). The heat has not dissipated as fast as it could have because there is also heat being added continuously by decay of radioactive elements and a few other secondary sources, but it would still be very hot inside the earth even if there had been no heat added since formation. The amount of energy that is making it to surface and leaving by radiation (infrared or black body emissions) is estimated to be about 50 % from radioactivity and about 50% from the continued cooling of a once extremely hot planet. The numbers are ballpark.
The sun has essentially no effect on the temperature of the inside of the earth. It does affect the temperature of the very near surface (tens of meters or perhaps deeper, a few kilometers, depending on how you want to look at it) and the temp of the atmosphere, but that has little to no impact on how quickly the heat deep inside the earth is able to make it up to the surface, which is all that affects the inside temperature.
The heat flow is way more intense from inside to outside than from outside to inside.