At first, the answer seems obvious, as E/h = f, where E is the energy of the photon, h is the Planck constant, and f is the frequency of the photon. But then one realizes that the photon would need an infinite duration in order to have a single frequency (e.g., Fourier transform relation, and Heisenberg uncertainty principle).
The probability doctrine of quantum mechanics (QM) asserts that the indetermination, of which we have just given an example, is a property inherent in Nature, and not merely a profession of our temporary ignorance from which we expect to be relieved by a future better and more complete theory.
Such more complete theory appears to be Quantum Field Theory (QFT). The Heisenberg uncertainty principle in QM may then have to be reexamined.
Obviously, then, E/h = f is not the correct answer.
Nothing is infinite in Nature. We can't wait forever to measure a photon, and nothing can. The Universe would not exist.
The answer is to realize that something is wrong with the QM picture of a photon. The frequency of a photon is defined by its physical conditions in QFT, not by itself.
And it is not described by a Fourier transform either, which is a mathematically "continuous" procedure -- with the hypothesis of infinitely close frequencies -- and should never be used to represent a discrete phenomena, or artifacts of the interpolation will appear.
As Juan Weisz asks -- why is QFT better than QM? The answer may be relevant here, as QM is subjective but QFT is intersubjective. Like math, it is not enough to be subjective, as follows.
QM is based on two deep untruths, as revealed by Nature, in addition to the rather formalist easy-to-solve fact that QM is not combining the principles of Lorentz invariance (SR-MINKOWSKI-EINSTEIN). They are:
1. One needs to abandon the single-particle approach of QM (subjectivity). In any relativistic quantum theory, particle number need not be conserved, since the relativistic dispersion relation in SR, that E^2 = c^2p^2 + m^2c^4, implies that energy can be converted into particles and vice versa. This requires a multi-particle framework (intersubjectivity), a many-body interaction with SR included and uses QM. It is a many-body-relativistic-QM, not just QM.
2. Unitarity (basically, preserving the inner product) and causality cannot be combined in a single-particle approach, requires intersubjectivity.
QFT solves these two problems by using a different approach:
A. The fundamental entities are not the particles, but the field, an abstract object that penetrates spacetime.
B. Particles appear as the vibrations of the field.
The physical model of the photon, for example, is given as a vibration of the EM field, and follows QFT. Then, in QFT the frequency of the photon does NOT depend on the photon itself and only (that would be subjective), but on its physical conditions in a many-body-relativistic-QM (intersubjective). Then, that intersubjectivity can obtain objectivity to different observers, in different experiments, at differing spacetimes.
See https://www.researchgate.net/post/What_is_wrong_with_Quantum_Mechanics
and
Sean Carroll recently at https://www.youtube.com/watch?v=rBpR0LBsUfM and after the 45 minute mark specially.