This is closely related to the OP with title "lining figures in tables and math, old style figures in text", and to the answer provided therein.
The following (semi)MWE is to be run with pdfLaTeX:
\documentclass[12pt]{memoir}
\usepackage{etoolbox}% I tried with \AfterEndPreamble
\usepackage{textcomp}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\AfterEndPreamble{%
\def\libertine@figurealign{}
\libertineOsF
\noindent% memoir indents at the very start
}
\begin{document}
Text figures: 0123456789
\par\noindent
Math figures: $0123456789$
\end{document}
It leads to lining figures in math mode and text (oldstyle) figures in text mode, but only on the textblock and not so on the headers, where we still get lining figures, as can be seen in the numeral for the page number.
How can we get oldstyle figures on the headers, too?