I can't have been the only one who accidentally dismissed Dogmeat, only to realise I couldn't get him back, and my last save was a few hundred raiders ago, right? Anyway, if you accidentally dismiss the pooch after bringing up his dialogue options (which you could easily do, as chances are you wouldn't even know you could tell him to leave you alone until you mistakenly did), he'll head back to whichever Settlement you pointed him towards. However, occasionally he'll still be wandering the vicinity of the safe zone itself, which is why you need to build a doghouse for him to come back to. Once you've got one at a Settlement, he'll soon appear within it - something you can prompt manually by Fast Travelling away from an area and back again.