What you want is called "[tethering][1]".

[Here][2] you can find apple's official stance on it:  
From that same page (when you click on 'How to use internet tethering'):

> Using iPhone as a Modem
> --
> You can use iPhone 3G or later as a
> modem to connect, or tether, your
> computer to the Internet. You can
> connect iPhone to your computer using
> the Dock Connector to USB Cable, or
> via Bluetooth.
> 
> NOTE: Additional fees may apply.
> Contact your carrier for more
> information.
> 
> Tethering works over the cellular data
> network. You can’t share a Wi-Fi
> connection to the Internet. If you
> have a 3G connection, you can make and
> receive phone calls while tethering.
> 
> NOTE: To use iPhone as a modem with a
> Mac computer, it must be running Mac
> OS X version 10.5.7 or later. 
>
>**Set up a
> tethering connection:**
> 
> 1. In Settings, choose General > Network > Internet Tethering.
>
> 2. Slide the Internet Tethering switch to On.
>
> 3. Connect iPhone to your computer:
>     * USB:  Connect your computer to iPhone, using the Dock
> Connector to USB Cable. In your
> computer’s Network services settings,
> choose iPhone.  
>
>       On a Mac, a pop-up window appears the first time you connect,
> saying “A new network interface has
> been detected.” Click Network
> Preferences, configure the network
> settings for iPhone, then click Apply.
> On a PC, use the Network Control Panel
> to configure the iPhone connection.
>           
>    * Bluetooth:  On iPhone, choose Settings > General > Bluetooth
> and turn on Bluetooth. Then refer to
> the documentation that came with your
> computer system software to pair and
> connect iPhone with your computer.
> 
> When you’re connected, a blue band
> appears at the top of the screen.
> Tethering remains on when you connect
> with USB, even when you aren’t
> actively using the Internet
> connection. 
>
> **Monitor your cellular data
> network usage:**
> 
> In Settings, choose General > Usage.

There's quite some [other ways][3] explained on the internet how to do it once you know which term to search for ;-)


  [1]: http://en.wikipedia.org/wiki/Tethering
  [2]: http://www.apple.com/iphone/iphone-3gs/tethering.html
  [3]: http://www.google.com/search?q=iphone+tethering