Let us think about phonons first. The general rule is that a classical normal mode becomes a quantum harmonic oscillator. While this sounds like I've just made up some random rule that works, in fact you can show this is a result of the schroedinger equation.
In homework problem 2.6 we showed that the rule is true for two masses coupled by some springs. If you wanted to be more general you could show that for any set of masses coupled by any set of springs, the quantum eigenstates are obtained by treating the normal modes as SHOs. (If you want to walk through the general proof, look at exercise 9.7 from the book).
Now in the case of photons it is more difficult. Here we are thinking about quantizing modes of the electric field. Since we can't identify any masses and springs that have classical normal modes, the fact that the electromagnetic field is quantized in this way has to be just a postulate (or a result of some other postulate) of quantum mechanics.