Well, the problem could be happenning everywhere, but would be most noticable in TF2. In most applications, your mouse moving an inch upward wouldn't be too noticible unless you were actively doing something with said mouse, but on TF2, an inch of movement would spin you pretty far (if you've got it on high sensitivity).
The first things I can think up off the top of my head without more information:
1) Dirt or hair (especially hair) inside the little hole for the laser. Look VERY carefully in there, probably with a flashlight, and see if there's anything in the way. Blow it out carefully, or in the case of hair, pull it out with tweezers. You don't want to scratch the lens in there.
2,3,4) If it's cordless: Low battery, interference, or too far from the reciever. Try changing the battery (does yours have a low battery light?) or moving the reciever closer to the mouse, and away from wires or your computer (especially the power supply and speakers).
5) Bad mousing area. If you're not using a mouse pad, use one. Make sure there's no especially shiny or dull spots, gaps, holes, scratches, pits, or dirt where you move your mouse.
6) Damaged mouse. Could be a scratched lens, broken stuff inside, whatever.
If it's none of those, it could be anything from a driver error to some background program temporarily grabbing focus from TF2 and leaving the game thinking your last input was to keep turning or looking up. If none of this helps, I'm sorry man.