do the resonance structures only apply for oxygen and double bonds?

No. Organic chemistry is over run with resonance structures. Most polyatomic ions in inorganic chemistry as well as many compounds have resonance structures.

how do you know when to draw the resonance strcutres?

Generally, when more than one structure CAN be drawn. That isn't always true but it is generally true. For example, I can draw

H:O:Cl: with two dots over the O and Cl and two dots below O and Cl. But I can also draw it as
H:Cl:O with two dots over Cl and O and two dots below Cl and O. However, these are not thought of as resonacne structures because it is known that H is not attched to Cl but to the O. An example might be NO3^- where the double bond can be placed at almost any of the N-O postions. So we draw the double bond to one N-O, then to the other N-O and call those resonance structures.

No, resonance structures are not limited to just oxygen and double bonds. Resonance refers to the delocalization of electrons within a molecule or an ion, and can occur in any molecule that has π (pi) bonds or lone pairs of electrons.

Pi bonds are formed by the side-by-side overlap of p orbitals, which are commonly found in double and triple bonds. Oxygen is frequently involved in resonance because it can have both lone pairs and pi bonds. However, other atoms such as nitrogen, sulfur, and carbon can also participate in resonance.

To determine if a molecule can have resonance, one should look for the presence of pi bonds or lone pairs of electrons. If a molecule has a conjugated system, where multiple alternating single and multiple bonds are present, it is a good indication that resonance is possible.

It is important to note that resonance structures are only a representation of the molecular structure, used to describe the delocalization of electrons. The actual molecule is a hybrid or a blend of all the resonance structures, called a resonance hybrid.