Mac OS X contains built-in firewall software, known as ipfw. You can use this to protect your machine from outside entry, but it's not trivial nor GUI-friendly. If you want that, go get Brickhouse from Versiontracker.
If you'd prefer to work directly with UNIX, Daniel Cote has published his ipfw configuration file, along with some tips on how to use ipfw in Mac OS X - you can read the article right here.
NOTE: You should really understand exactly what it is you're doing before you going mucking about with the firewall software! For a more simplistic approach, try Brickhouse or any of the hardware routers.
Mac OS X Hints