When you sync your iPhone (either auto or by selecting sync) iTunes should recognize that you have an app on your phone that is not in your library and it will ask if you want to transfer it to itunes. Works the same way for music downloaded via the wi-fi itunes store.