iLounge has noticed that, when connecting to an accessory that supports iPhone 3.x SDK's dock access abilities:

an alert box labeled “Application Not Installed” appears, informing users that the accessory requires an application which is not currently installed, and asking if they would like to install the application from the App Store. Upon acceptance, the iPhone or iPod touch then takes users to a new “For This Accessory” page on the App Store, with a direct link to the necessary app’s listing, from which they can download and install the application.

They show how it works for the iTrip, but this is a very "just works" solution in general for users who may not be aware when companion apps are available.