The Sun generates energy deep in it's core through nuclear fusion that burns Hydrogen into heavier atoms. As the atoms merge, energy is released, and begins the long journey toward the Sun's surface. Along the journey, energy is transferred via two of the the methods of heat transfer: convection and radiative transfer.
Since heat energy always flows from hot to cool regions, solar energy travels outward from the hot core and through to the cooler upper layers of the Sun. Throughout most of the Sun's volume, energy moves primarily by radiation. That is, the energy radiates through the gas in the form of electromagnetic radiation, just as light travels through our atmosphere. In this way, a photon of light is released during the fusion process, and then travels a small distance before scattering off a new atomic nucleus. This absorption starts the photon on a long and random journey of emission and absorption that will eventually carry the energy upwards. This is a slow process since each re-emission is in a new and random directions. The radiative zone begins about 25% of the way out from the Sun's center and extends to 0.7 Solar radii, and it can take a photon more than 50,000 years to traverse this distance.
Once out of the radiative zone, energy is able to transfer much more quickly. Absorbed photons heat pockets of gas that begin to rise like hot air balloons through the solar atmosphere. Convection occurs when the temperature difference between the hot and cold regions in a fluid or gas like material is so great that radiation cannot carry off the outward-bound energy fast enough to equalize the regions before density differences lead to motion. Large bubbles of gas, having become heated enough to expand, become less dense than their surroundings and rise toward the surface. Once there, they cool by radiating their energy into space (as sunlight), and as they cool they shrink, thus increasing in density until they sink. This is just what happens in lava lamp with a lightbulb at the bottom heating oil, which rises and radiates its heat at the cool top of the lamp before sinking back down and restarting the process. It's also what happens when you bring a pan of water to a rapid boil.
Over the hundred thousand years it takes energy to diffuse to the Sun's surface, the energy is able to spread out over larger and larger areas. Over the volume of the Sun, the temperature drops from 15 million Kelvin at the center to just a few thousand Kelvin at the surface. The visible surface of the Sun, or the photosphere, corresponds to a low enough density that photons no longer collide on their way out. At this point they travel freely through space. After the many many millennia journey through the Sun, the last leg of the light's journey toward Earth only takes 8 minutes. Each ray of sunlight that touches your skin started it's journey just as modern man first began to walk the Earth.
An annotated look into the Sun's interior. Click here for original source URL