Originally, there were ads only on the three oldest sites in the network: Stack Overflow, Server Fault and Super User. You'll see fewer ads if you visit while logged into an account with more than 200 reputation. Nowadays some of the other high-traffic sites have ads; see What sites have advertisements enabled? for a list.
Some sites have ads chosen by the community, via threads such as this one. These are present on graduated sites (i.e. sites other than the SO/SF/SU original trilogy and “special” sites such as this meta site and other than the young sites that have a beta status) as well as SF and SU.
SO has something similar with the restriction that only ads soliciting developers to participate in open-source projects are allowed.