1. There’s a sort of diffusion process going on. Photons from the core have some mean free path as a function of radial position (and, obnoxiously, of wavelength as well, so maybe we ignore that). You could calculate the mean time for a hypothetical object emitted from the core and traveling according to those mean free paths to escape.
2. You could imagine you have marked a photon and watched it travel. This is quite problematic. First, photons in thermal equilibrium obey Bose-Einstein statistics because they are indistinguishable bosons, and anything that could mark them would change the statistics to that of distinguishable particles. But whatever, the temperature is high and maybe this doesn’t matter. Also never mind that those core photons are mostly much shorter wavelength than the photons we see. But you can still imagine. (The answer is probably quite similar to #1 since this is sort of the same problem depending on how you think about the interactions with matter in the sun.)
3. You could calculate how long it would take to notice anything if the core suddenly stopped fusing.
When you have a transparent medium like water or glass, the photon that enters and the photon that exit share a lot of properties, in particular energy/color/frequency. Perhaps they have a shift in the phase or a different polarization (like in water with sugar or if you want to be fancy a quarter wave plate). You can still split a beam before in enter and make interference experiments after half of it passed though water or glass, and other weird experiments, so I think it's fair to call them "the same photon".
But in the Sun, the original photons in the center of the Sun have a few very specific values of energy/color/frequency, that are totally lost. (But the neutrinos have so few interactions that they don't lose this information, and it's possible to do neutrino spectroscopy!)
Also, the photons emitted by the "surface" of the Sun have a wide spectrum of energy/color/frequency that is very close to black body radiation at something like 5000K-6000K.
So in my opinion it's better to think that the original photon in the center is absorbed shortly after it's emitted, and transformed into heat. The heat takes 5000 years to get to the surface. And then the hot surface emits a few new photons unrelated to the original one.
I'm not sure what is the main transmission method inside the Sun: conduction, convection or radiation.
[0] https://scholarship.haverford.edu/cgi/viewcontent.cgi?articl... Eq. 16 [1] Handy plot at https://commons.wikimedia.org/wiki/File:Quantum_and_classica...
> You could calculate how long it would take to notice anything if the core suddenly stopped fusing.
FW(little)IW (very not my field, just AI, quick&sloppy), for a Sun magically switched to contraction-dominated heating, I'm sloping order 10^6-7 yr for a 1% increase in surface temp, with core contraction dynamics being just one uncertainty.
However, as the photon collides with other particles during its random walk, some of its energy is transmitted to those other particles. Sometimes a collision transfers energy to it too.
In a simple model, the energy that originally belonged to the photon gets transmitted from particle to particle through convection, and can escape the star through radiation long before the original photon reaches the surface. I don’t think that model is supposed to be physically accurate, rather to be an illustration about the convention process inside a star.
But photons are generated in the core through nuclear reactions, where they take their sweet amount of thousands of years bouncing around until they get out.