What is temperature in the classical entropy definition? Entropy change for a system is defined classically as:
$$dS=\frac{\delta Q_{rev}}{T}$$
where $\delta Q_{rev}$ is infinitesimal reversible heat that flows in a system.
I don't understand whether $T$ refers to the temperature of a system or its surroundings. Many sources said $T$ is the temperature of a system. However since this entropy definition applies to reversible processes and most reversible processes have a system in thermal equilibrium with its surroundings, so $T$ refers to either system and surroundings because temperatures in equilibrium are equal.
To calculate the entropy change when a system changes its temperature from $T_i$ to $T_f$:
$$\Delta S=\int_{T_i}^{T_f} \frac{\delta Q_{rev}}{T}$$
This integral assumes that the path we are integrating is quasistatic and reversible. If $T$ refers to either system and surroundings, then that means in the selected quasistatic and reversible process, the temperature of both system and surroundings change from $T_i$ to $T_f$?
Also, when the definitions of Helmholtz and Gibbs free energy are discussed
$$F=U-TS$$
$$G=H-TS$$
Schroeder wrote that the term $TS$ refers to heat that flows in a system where $S$ is a system's final entropy and $T$ is the temperature of surroundings. Can $T$ refers to the temperature of a system?
 A: For a reversible process, the temperature of the system is spatially uniform, as is the temperature of the surroundings.  So the temperature T refers both to the system temperature and the surroundings temperature.  If the system temperature is changing between the beginning and end of a reversible process, so also does the surroundings temperature change.  In the case of the surroundings, we typically envision what is happening is the system being placed in contact with a continuous sequence of constant temperature reservoirs with temperatures running from $T_i$ to $T_f$.
For an irreversible process, the temperature of the system may not be spatially uniform, and the temperature of the surroundings may not be spatially uniform either.  But, at their interface through which the heat flows, their temperatures will match. In the Clausius inequality, we use this temperature at the interface $T_I$ to express the condition that $$\Delta S>\int{\frac{dQ}{T_I}}$$
A: 
I don't understand whether  refers to the temperature of a system or
its surroundings.

$T$ refers to the temperature at the boundary between the system and the surroundings. If the surroundings is a thermal reservoir, then $T$ is the temperature of the surroundings. If the system is in thermal equilibrium with the surroundings, then $T$ is the temperature of both the system and the surroundings, not just at the boundary.

If $T$ refers to either system and surroundings, then that means in
the selected quasistatic and reversible, the temperature of both
system and surroundings change from $T_i$ to $T_f$?

Yes they do, but for the process to be reversible the system has to be in contact with an infinite series of thermal reservoirs ranging from $T_i$ to
$T_f$ with each subsequent reservoir having a temperature infinitesimally greater than (or less than) the previous reservoir, so that the system is constantly in thermal equilibrium with its surroundings.
Hope this helps.
