Activating effects of amino and hydroxyl groups in different pH
Both the amino and hydroxyl groups activate benzene rings, as the lone pairs on N or O are in conjugation with the benzene π system.

However, in acidic media, the amino group is protonated to form an ammonium cation. Now, the lone pair on nitrogen is no longer available: it has been used to make a new N–H σ bond.



Consequently, the $\ce{-NH3+}$ group no longer acts as an electron donor via resonance. Instead, it is an electron-withdrawing group via the inductive effect (neutral amines are, too, but the resonance donation far outweighs the inductive withdrawal). For further details, you may wish to read this question: Is the ammonium substituent (-NH3+) really meta-directing in electrophilic substitution?



Phenols, on the other hand, can be deprotonated in basic media to form phenolates. Perhaps unsurprisingly, this has the opposite effect from before: the negatively charged substituent $\ce{-O^-}$ is even more electron-donating than the neutral hydroxyl group.



It's tempting to think that this is because "there are more lone pairs on oxygen", but that's not the truth. In order to have maximal overlap between a lone pair and a π system, they must be parallel to each other: on this oxygen, there can only be one lone pair which is parallel to the benzene π system. So, whether a substituent has two or three lone pairs doesn't make all that much of a difference.

The explanation is, instead, to do with the availability of the lone pair. We could think of the neutral phenol as being the same as the phenolate, but with an extra proton which is pulling one lone pair on oxygen towards it. This stabilises the lone pairs, and therefore makes them "less willing" - in a sense - to be delocalised into the benzene ring. (Technically speaking, the lower energy of the lone pair makes for a poorer energy match with the benzene ring LUMO.) In the deprotonated phenolate, though, there are three lone pairs around oxygen which repel each other. This means that they are higher in energy, and are more delocalised into the benzene ring.

As a result, phenolate reacts with very poor electrophiles such as $\ce{CO2}$ (Kolbe–Schmitt reaction) quite well.