Do photons slow down this much in the Sun's gravitational field? I just heard someone mention that photons take 40 thousand years to travel from the centre of the Sun to its
surface which is roughly 700,000 kilometres. How is that possible  if the speed of light/photons is 300,000 km/second?
 A: Gravity has little to do with it.  The sun is a dense plasma and particles of plasma  prolifically scatter photons (both elastically and inelastically). Hence the photon does not travel from the center to the surface in a straight line.
A: Well, photons always travel at the speed of light (in a vacuum and in this case between particle collisions - see below) about $3 \times 10^8 \ m/s$ and they are being slowed down in this
scenario, but not the way you think and not because of the suns' gravitational field.
You should also note that the photon emitted at the centre of the sun and the one escaping
at the suns surface are not the "same" photon.
Because the sun is very dense, a photon emitted at the core will be absorbed by another nearby proton almost immediately, and the proton will vibrate then re-emit another photon in a random direction. This happens over and over again trillions of trillions of times so that by the time it reaches the suns surface, thousands of years have passed.
This process is described by what is called a random walk.
The distance that a photon can travel before it is absorbed, is given by what's called the
mean free path and is given by the relation
$$l = \frac{1}{\sigma n}$$
(from Wiki) "where $n$ is the number of target particles per unit volume, and $\sigma$ is the effective cross-sectional area for collision."
As you can appreciate, the number of target particles (protons) will be significantly high making this distance extremely small, so that effectively, the photon travels a "vast distance" from within the Suns' core to its surface, taking thousands of years. Then it takes a measly 9 minutes to reach us!
A: I should to clarify that gravitational field changes the wavelength of light (consequently the momentum of the photon in the vacuum) but not the speed of the photon since $$ p = \frac{\hbar}{\lambda} $$ and the speed of light in the vacuum remains absolute according to the relativity principle.
The reason of the apparent slow down of the speed of light in the sun is explained extensively in the previous answers.
A: The energy produced in the core takes that long to reach the surface.  It's not the same photon taking that long.  Photons are constantly emitted and absorbed, and the energy also spends time as kinetic energy of the electrons and protons in the plasma.
The core gets hot.  It takes 40k years (or whatever the correct number may be) for it to cool, working its way though the entire bulk of the sun's material.
