I personally has heard many people asked "How to write an exploit ?" including myself. I begin my journey of answering this question. I can recommend the following sites which I rely on to guide me on this journey.
A list to help people in process of learning exploit
This an excellent place to start if you are a complete noob.
Corelan Exploit Writing Tutorials
This site contains step by step guide to write exploits. Corelan provides additional theory and explanations needed to write exploits.
Exploit writing tutorials by LUPIN
This site contains step by step guide to write exploits. Another great source to go to learn how to write exploits
Wiki on writing exploits
This wiki contains a lot of references on articles related to exploit writing. I don't recommend to start here if you are a complete noob.