For starters, like almost every question that begins "is it illegal", the real answers are always:
- It depends on where you live, so
- Ask an actual lawyer.
Having said that, it is not illegal to sell a used mattress in any United States jurisdiction that I know of. However, most states have restrictions on what you can and can't do when selling used mattresses, primarily involving fraud or health concerns.
For people who sell bedding as a business, the rules are rather strict, frequently requiring licensing from the Health Department, among other things. Many states (20 as of 2/10/2013) are part of a national cooperative, the International Association of Bedding and Furniture Law Officials, that attempts to synchronize bedding laws. You can read all the various requirements that member states adhere to on their site.
For a consumer selling bedding to another consumer, you avoid many of the regulations. What's left typically boils down to two things:
In some states, it may be a legal requirement that the bed include a label stating that it includes second-hand materials. Often this requirement only applies to retail or wholesale sellers, as in California's Business and Professional Codes, Section 19123, but other states, e.g. Wisconsin Statues, Section 100.2095 or Florida Statues, Title XXXIII, Chapter 501, Section 145, the law can be read as applying this requirement to all sales. If you haven't already ripped it off, your mattress probably has a label that says exactly the opposite, so you will need to be careful and See #2 Above.
You may need to have the mattress officially sanitized. For example, in Delaware, Title 16, Chap. 21, § 2105. Selling or leasing used mattresses; sterilization and disinfection, says:
(2) Any secondhand mattress, pillow, bolster, featherbed or comfortable, unless since last used it has been thoroughly sterilized and disinfected by a reasonable process approved by the Department of Health and Social Services.