Why did the F-104 Starfighter have a T-tail?
The initial preliminary designs had the horizontal tail in multiple locations (including in-line with the wing and cruciform), before settling on the T-tail by December 1952. The reason for selecting the T-Tail is given by Glenn L. &quot;Snake&quot; Reaves, Lockheed Production Flight Test Pilot in the F-104 Test Pilot notebook as

The high tail position was selected ... after extensive wind tunnel tests (which) proved that the location was necessary to obtain optimum stability and control about the pitch axis throughout the wide Mach range. The position also results in minimum transonic trim changes while accelerating to supersonic.

Another advantage was that the high tail on the swept vertical fin reduced interference drag. While the problem was inertial coupling was quite well known during 1950's, the design of the F-104 was frozen during the same period, so it is difficult to tell conclusively if that is the reason for F-104 having a T-tail.
The test pilot notebook also has some explanation about how the T-tail reduces the problem of inertial coupling:

If we now consider two facts about these rolling maneuvers, it will become clear how inertial coupling builds up:

The sideslip build-up is controlled by the induced rolling moment.

As sideslip builds up, the centrifugal or rolling forces increase and this tends to displace the aircraft fuselage perpendicular to the flight path.



The T-tail controls the the sideslip build-up by inducing a rolling moment. From the same document:

... the high tail position of the horizontal stabilizer raised the center of pressure.


Image from F-104 Test Pilot notebook

... whenever we sideslip an aircraft, a rolling moment is induced that resists the sideslip. This induced rolling moment is generally termed dihedral effect.
... with any sideslip, the restoring force acting through the center of pressure does not act through the c.g of the aircraft. Therefore, a sideslip condition actuates the restoring force on the tail but at the same time, induces a roll. ... now that we have raised the tail and consequently the center of pressure and the positive dihedral effect has been increased considerably.

The T-tail reduced inertial coupling by preventing sideslip buildup.