Often, the first step in a transaction like this is for the company to learn more about your recipe so that they can evaluate whether they want to purchase rights to it and, if so, how much they are willing to pay to obtain such rights. In many cases, this will involve signing a non-disclosure agreement with the company, pursuant to which they agree to only use the information that you provide concerning the recipe for evaluation purposes.
If, once the evaluation phase is completed, they are interesting in purchasing rights to the recipe, you and the company will have to determine the terms of the agreement. Here are some examples of issues that may arise during negotiations:
How much will they pay you?
Will the money be paid up front? as a royalty, based on their sales of products made using your recipe?
Will you be obligated to be available to answer questions regarding the recipe?
Are their any trademarks associated with the recipe that they will also be obtaining?
Will you have the right to continue sell products made using your recipe?
Do you have the right to sell the recipe to another company?
What happens if they stop making products with your recipe?
My comments in response to your question are intended to provide general information. If you plan to proceed with a transaction like the one that you describe, I urge you to retain competent legal representation.