As the Pyro ...
Obviously, what the Pyro has going for him is fire. Players caught on fire will visibily burn.
Unlike the Medic's "tropical disease", fire damange will eventually end after a while. The
damage is not extreme, but enough to perhaps kill those who've seen a lot of action. Also,
water will (sometimes) put out fire. It all depends whether you were totally in the water when
the flame hit.
The Incendiary Cannon is the Pyro's long range weapon. What it lacks in "oomph", it makes up in blast radius and annoyance. True, you're not likely to kill anyone outright with it, but you'll most certainly make them easier to kill later on for your teammates, or yourself. Also, use it to light Snipers on fire, so your team can spot where they are hiding.
The Flamethrower can be especially deadly. All it takes are a few seconds to toast someone to a crisp. Since the Pyro is faster than the heavier classes (Hwguy, Soldier), it won't be hard to keep them in the flame. However, those are the classes most capable of killing you (with a rocket or a quick sweep of the AC), so be careful.
The Napalm grenades are somewhat like the IC in terms of damage. They'll definately hurt your opponent, but probably won't kill them. Use normal grenades if you need a quick, killing, blast. Use napalms in a crowded room with lots of (hopefully wounded) enemies.
Unfortunately, Sentries don't take additional flame damage. If there's a gun which needs to be destroyed, use your regular grenades or get a teammate to help you out.
Against the Pyro ...
Avoid fire if possible. But don't let that consume you. If you're close to full health, you
should be able to take the damage rather easily. Otherwise, head to water or the resupply room.
The Flamethrower especially can be a pain, especially if you're a slow class. If a Pyro is on
your tail, try to kill him first before he can toast you. (This might mean firing backwards or
bouncing grenades behind you)
Otherwise, treat the Pyro just as you would the Medic or Demoman. His range weapon isn't very powerful, but he has some speed to compensate.