It is your right to send a letter telling a collection agency to stop phone calls. They can continue to email and send mail through the post. If the debt is sold, you must make the "stop calling" request again.
In some states, you can have a collection agency stop calling you by telling them that you will not pay. This has no effect on their right to sell the debt, however. Such sales are actually very common.
It is only illegal for them to keep calling after you have said to stop calling. It is legal for the company to sell the debt. If they sell the debt and you said not to call, then they must inform you of the sale of the debt, usually in writing.
It is legal, especially if you owe the debt. For example, if you owe money to a doctor and his office can't collect on it and you ask them to stop calling you, it is legal for them to sell your debt to a collection agency to collect on.