Here are some links that discuss the steps. Hope they help!
http://msdn.microsoft.com/en-us/library/bb250997.aspx#BCWith
http://platinumdogs.wordpress.com/2007/12/17/deploy-an-infopath-2007-form-with-managed-code-to-a-browser-enabled-sharepoint-document-library/