Do you mean licensing an application that you've created?
You choose a license (if going open source), or create one (if you intend to sell it), and include it in the application usually as a readme.txt, inside the application (in like a help window), or displaying a license agreement before the install of the application (if your application is installable) that they must accept.
As for preventing piracy of a for-sale application...well that's a very large issue and a very difficult one to bypass.