You join the Made for iPod and Works with iPhone Licensing Program - it involves a few NDAs and legal documents, then they give you the specifications for connecting with and communicating through the i/o port or bluetooth.
Here s a blog post detailing what one person went through to get into this program and gain access to the documentation:
Part 1:
http://www.stackoverthrow.com/?p=97
Part 2:
http://www.stackoverthrow.com/?p=100
It looks like there s no extra fee (above the usual $99 developer program fee) but there s a lot of back and forth paperwork, including faxes, mail, etc which stretched the process out for him to nearly 2.5 months.
He hasn t given much of the nitty-gritty details, so there may be more to it (ie, you may have to disclose your intended application, and if they don t like it they may turn you down) but it gives the process from a recent program applicant. Would be nice if it changed so it was all online, but I m thinking they may still require all the paperwork.