This is completely between you and the journal in which you publish your article.
If you publish in a Gold Road Open Access Journal, you will automatically retain copyright; it is part of the contract. In exchange, you will sometimes pay an author fee of between $200 and $5000.
In so-called hybrid Open Access journals, the journal's default is to keep your content behind a paywall, but they may charge an author fee for you to self-archive a pre-print (but not the article in its final published form.)
If the journal is not Gold Road or hybrid Open Access, you can always negotiate, using the SPARC Author Addendum or a similar legal instrument.
You can check SHERPA-RoMEO to see what your journal's terms of Open Access are.
SPARC is an organization dedicated to expanding Open Access, Open Data, and Open Education.
The SPARC Author Addendum is recommended to add to the publishing contract that is offered to you by the journal. It is free to use, and it is a valid legal instrument.
Note that the SPARC Addendum doesn't say or imply that you'll pay a fee, and it does grant you the right to archive the published version of your article. The journal may reject or insist on modifying this addendum, however it's a good place to start.