Copyright law presents a simple premise: that creators, artists, and authors should be rewarded economically for contributing to the marketplace of ideas. The system in place protecting copyright gives authors the exclusive ability to transfer and negotiate their copyrights through assignment, transfer, and licensing. Not all rights are treated equally, however, and it is important to understand exactly what you're transferring away when you sign the dotted line.
Having a Right to Sell
Before you can think about selling your work, you need to know that you are the owner. If multiple people contribute to a work (e.g. collaboration project for software creation), each contributor is a joint author and owns the work much in the same way that a tenant in common in real property owns land: each joint author has an undivided possessory interest in the whole work. This means that without a contract stating the contrary, everyone who contributes to the project is a joint owner subject to the interests of the other authors.
This can be problematic. For example, if you want to sell your product to a publisher, you will probably be required to sign a contract that assigns all rights to distribution to the publisher. You can't do this if you are a joint author unless you have permission from the other joint authors. There are limitations to this rule. For instance, a joint author can license certain non-exclusive rights independently so long as that joint author shares the profits with the other joint authors.
Joint authorship is something to keep in mind if anyone could potentially claim a stake in your work. Unfortunately, the law concerning joint authorship is a bit ambiguous and jurisdiction dependant—the only real bright line rule is that the contribution must be more than "de minimus" or more than a minimal amount.
If you work for a corporation or on behalf of an organization your work may be a work-for-hire. This means that the author (you) do not own the work under Copyright law. Instead, the company employing you automatically owns the rights to anything you create within the scope of your employment. Because the limitations on work-for-hire are also fairly ambiguous (for instance, if you work on a personal project after hours on a company computer, the project may still belong to the corporation) it is important to make the limitations clear in your employment contract.
Selling your Work
There are various ways to profit from your work, including exclusive licensing, non-exclusive licensing, and assignment/transfer.
An exclusive license gives the licensee (the purchaser) the sole right to use the work in the limited manner stated in the license. They are typically recognizable by language ("exclusive right") and a limitation in scope, region, and time. For instance if the licensor (you) grants licensee an exclusive right to distribution within the territory of Japan for three years, the licensee is the only entity that can distribute your work within Japan for three years. Keep in mind that when you grant an exclusive license to someone you aren't permitted to use or exploit the work in the manner described in the license during the term of the license; exclusive means just that, and it excludes you too unless you reserve certain rights. Once the license expires (in this case, after 3 years), the licensee retains no right to distribute your work unless the contract states otherwise.
A non-exclusive license gives the licensee the right to use the work in the limited manner stated in the license. Read that carefully. Only the right to use is granted. Keep in mind that no one but you may participate in any of the enumerated rights under copyright law without your permission. An example is a sync license for music. Unless the contract states otherwise the right to use a song in a movie is non-exclusive. The music publisher may re-license that song to any other licensee.
Note: You cannot grant an exclusive license when non-exclusive licenses are outstanding. If you've granted several people a non-exclusive license to use your work for an indefinite or infinite period of time, you will have to retain some kind of right of revocation or termination if you ever want to license your work exclusively.
Bear in mind that if you add or change your work in any way you essentially create a new copyright in a new work. If you grant a non-exclusive license in a piece of software and later change that software (by, say, adding new functions), you can sell an exclusive license in spite of the previous software unless the licensee demands otherwise.
If you assign or transfer your work you are no longer the owner of the copyright. If you see the words "assign" or "transfer" in a contract you should bear in mind that you will not be able to get those rights back unless the contract contains an option to repurchase. The purchaser can register the transfer document with the Copyright Office and be listed as the owner. However, copyrights are severable. You can transfer the public display or public performance right while retaining the right to distribute if that is made clear in the contract.
The key point is that it is important to know what you are selling. If you believe that you are selling an exclusive license but are in fact selling (according to the contract) an assignment/transfer you may wind up violating a copyright in your own work and have that copyright enforced against you.