I think that every device has its own behaviour, so I don't know if there is some setting that can be used as a general solution.
In example, I have a Kobo ereader, and it is capable to do what you ask; if there is a custom font inside the ebook, and it is used only for titles or some paragraphs (i.e. to format code in computer science books), for the rest of text without any particular formatting it falls back to the default settings.
Kobo ereaders also have many customization setting for the ebook typography.


In my experience, if I change them (expecially by selecting a non-default font), they will take the precedence over any formatting inside the ebook. Thus the order of precedence is like that:
custom font settings
> ebook internal formatting
> default ereader settings
.
In example, for books containing code usually it is displayed with a fixed width font, and if this font is included in the ebook and the relative text is correctly styled, it is displayed like that, overriding the default settings; but if I change my own visualizations settings, it will override also any particular styling declared in the book itself, for every bit of text. If in the "justification" setting I choose "aligned to left", it will do so not only on the main text body but also in titles and every other bit of text.
But this is the how Kobo readers work, I don't know if other devices have the same behaviour. Your best bet is to test your ebook in as many devices as possible.