There is no current API for this.
What those applications do is implement the raw functionality - ie. the HP app for printing to HP printers opens a raw socket connection to the printer and converts the document to be printed into the raw format for the printer. So it may be converting the PDF document into PCL for example. There is no iphone API for PCL, so you would have to read the PCL specification and learn how to generate it "by hand", or find a library from another platform you can port onto the iphone.
The problem is, there are a large number of printers, some speak PCL, some speak postscript, some speak custom languages - it is a large task to implement them all.
Some of the apps in the appstore rely on you having a PC, and they install a piece of software on the PC - effectively all these are is a frontend to send the document to the PC to be printed, using the printer drivers already present on the PC.
Apple have stated that they will be releasing printing for the ipad - ipad printer support confirmed by Steve Jobs. Presumably that will involve an API other apps can use, and it seems likely that will eventually come to the iphone too.