How can I stop Dogmeat from following me in Fallout 4?
This depends on what you mean by "stop following you". You can communicate with him (press the talk button) and tell him to stay. You can also tell him to go to a dog house if one exists (or build one for him if one doesn't although there is one in Sanctuary). This will get him to stop following you until you next fast travel.
If you want him to actually leave you alone so you can continue on your journey without a companion, you need to speak to him and select the "Dismiss" option, which will pop up a menu asking where you want to send the companion to.
Alternatively you can take another companion with you.