Why can the surface temperature of a star be calculated using the Stefan–Boltzmann law? I calculated the surface temperature of the sun using the energy flux of the sun and the Stefan-Boltzmann equation, as is seen in the beginning of this post, but I am confused on how this gives the surface temperature of the sun. Is the T we calculated not the average temperature of the star, since we calculated the temperature necessary to produce the intensity of the sun?
To put it in other words, if I increased the temperature of the center of the Sun, would this not increase the intensity and therefore the surface temperature of the sun?
The only "answer" I can currently come up with is that, by definition, the surface temperature of the sun is just the intensity/energy on the surface, so the statements above must be true. I am unsure if this is actually correct or if there are better justifications.
 A: The temperature you get is the "effective temperature", which is by definition
$$T_{\rm eff} = \left(\frac{L}{4\pi R^2\sigma}\right)^{1/4}\ ,$$
where $L$ is the luminosity and $R$ is the radius of the photosphere (the Sun does not have a surface).
Most of the flux we receive from the Sun comes from a thin ($<1000$ km) layer called the photosphere. It is in this layer that there is a transition from emitted photons being absorbed before they can escape, to emitted photons being able to escape freely. Since this transition does take place over a relatively small distance (compared with the size of the Sun), it also spans a relatively small range of temperatures (maybe about a 1000 K range for most of the photosphere, with a very small fraction of the photosphere being cool sunspots or bright plages with temperatures of around 4000 K and 10,000 K respectively). This means that the spectrum of the Sun is a summation over regions with a comparatively small range of temperatures that can be characterized quite well by this effective temperature.
In other words, the effective temperature is the temperature of a blackbody radiator that would emit the luminosity of the Sun if it had the radius of the photosphere.
The effective temperature does not directly depend on the interior or core temperature. That is because radiation from these regions is absorbed before it can escape, so we do not see it. The effective temperature only depends on the luminosity and radius as shown above. Thus if you increased the core temperature, the fusion rate and luminosity would increase. Whether, or by how much, the effective temperature would increase would also depend on by how much the radius of the Sun increased in response.
A: The other answers are good, but here is a simple explanation:
Think of the thermal radiation as a heat exchange.
It is the surface that participates in the radiative heat exchange. The interior can do whatever it likes; it is the surface temperature that matters in regard to the heat exchange.
(Well, this is absolutely true only as far as whatever you understand as "surface" is opaque enough. The sun is very good in this regard, but it is not absolute.
The "surface" is somewhat transparent to ultra-low-frequency electromagnetic waves. This is how the magnetic reconnections and other impressive processes happen outside of the photosphere.
The solar corona is heated to millions of K by heat-exchanging with much hotter internal layers of the Sun, using this photospheric "spectral window".)
A: You are right, the answer you get this way is the temperature of the sun's photosphere (what we call the "surface" of the sun even though it is not a solid surface). Remember also that the temperature of an object is the mean of a distribution of energies possessed by all the atoms in it, so in this sense the "averaging" has already been done for you.
Note also that events in the core of the sun that produce energetic (gamma ray) photons do not communicate those photons immediately to the photosphere. This is because the mean free path between inelastic scatterings is short enough that it takes tens of thousands of years for those photons to rattle around and finally make it to the photosphere and stream off into space. By that time, they are photons of light with a characteristic black-body spectrum, possessing a well-defined temperature.
A: 
Is the T we calculated not the average temperature of the star, since we calculated the temperature necessary to produce the intensity of the sun?

No

To put it in other words, if I increased the temperature of the center of the Sun, would this not increase the intensity and therefore the surface temperature of the sun?

This is complicated, actually. Stars must obey hydrostatic equilibrium, so their density and temperature as a function of radius will be whatever they need to be so that the central density/temperature produces enough nuclear fusion to keep the star from collapsing under its own gravity. You cannot simply change the temperature at the center. Actually, when a heavy-enough star is shell burning, the energy input can cause it to become a red giant, therefore actually decreasing the surface temperature while the central temperature increases.

the surface temperature of the sun is just the intensity/energy on the surface

Yes, this. You cannot see the layers of the Sun under the photosphere because there is so much plasma in the way--the layers underneath are opaque. The center of the Sun has a temperature of millions K whereas the surface is thousands K.
A: A way to think about it is this:
The sun is stable - at least for now, and on a quite long timescale. By definition, that means energy is on average neither accumulating, nor dissipating, to a great degree, over periods of tens or so millions of years, for example.
But that implies energy released roughly equals energy dissipated. Energy released is fusion in the core. Energy dissipated is radiation and particles leaving the surface.
So we expect these to be close to equal, despite everything else - despite the time taken for photons to exit, the solar neutrino flux, and everything else.
But we know the energy leaving the surface is roughly, blackbody plus solar neutrino flux (and a few other things). We know the energy released by fusion per second. So we know how much must leave the surface per second as well. They must be almost exactly the same. We can allow for non-EM losses (neutrinos, gravitational losses if any, etc.). what's left is black body radiation, at some amount of energy per second, through a surface of some number of sq.m., equalling some amount of watts. Do the mathematics and we find the surface temperature needed for the sun to lose that much energy per second. Easy.
So it’s not an average or whatever. It’s the temperature needed to create the sustainable star we see, whose energy budget is balanced.
