But my question is that if light is made up of quanta, one quantum of electromagnetic energy is called a photon.
Frequency is a well defined number in the classical electromagnetic wave. It is defined by the change in the amplitude of the electric and magnetic field in space and time.
Then how can photons have a frequency since photon is a particle. So how can the formula E=hf be used
The classical wave emerges from zillions of photons, not in an additive way like water molecules in a stream, but in a superposition of the quantum mechanical wave function of the individual photon that build up the classical wave of frequency nu.
The wave function of the photon in its complex amplitude

carries the information of the frequency which will be seen in the varying electric and magnetic fields of the emergent classical beam.
Measurement of the photon itself can only give the energy and the spin orientation. It is through the formula E=h*nu that the energy of the photon defines the frequency that would manifest a classical wave of frequency nu, for a large ensemble of photons with energy E.
This link might help get an indtuition of how photons build up the classical wave.