
Ideally, you would have your QMS in place before the development phase starts. In reality, most companies implement it during the development phase, since the QMS includes your processes for design and development. You don't have to wait until your device is on the market to implement the QMS.
For certification, it's a bit different. You can (and should) have a working QMS before or during development, but certification (like ISO 13485) is typically required before you go to market. In the EU, if your product is class IIa or higher, you'll need a notified body to audit your QMS as part of the conformity assessment, usually before they review your technical documentation.