If you accept a quick-n-dirty solution that needs to be adjusted by hand, the following simple trick will do:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\newcommand*{\allowinlinmathbreak}{\penalty \exhyphenpenalty}
\begin{document}
We first left the DC loop open and inputted AC at a frequencies of ${50, 51,
67,\allowinlinmathbreak 95, 102, 127, 147, 150}$ Hz into the AC loop.
\end{document}
A better solution would be to make the comma active in math mode and to define it to insert a comma followed by the \penalty item, but I haven’t got time to write it now (surely somebody else will before tomorrow!).
Addition
Well, in the end I’ve found the time to develop my idea:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\newcommand{\allowinlinemathbreak}{\penalty \exhyphenpenalty}
\newcommand{\allowinlinemathbreakatcommas}{\mathcode\,="8000} \newcommand*{\oldcomma}{} % to reserve the name \edef\oldcomma{\the\mathcode,}
\begingroup
\lccode\~ =,
\lowercase{\endgroup
\def~{\mathchar\oldcomma\allowinlinemathbreak}}
\begin{document}
We first left the DC loop open and inputted AC at a frequencies of
$\allowinlinemathbreakatcommas {50, 51, 67, 95, 102, 127, 147, 150}$
Hz into the AC loop.
The meaning of the comma is changed only locally:
We first left the DC loop open and inputted AC at a frequencies of
${50, 51, 67,\allowinlinemathbreak 95, 102, 127, 147, 150}$
Hz into the AC loop.
\end{document}
Anyway, although I have to admit that your question does make for an amusing puzzle, I cannot fully understand why you insist on placing the numbers inside a set in math mode, instead of simply writing the numbers separated by commas and spaces in ordinary text: is it a notation meant to suggest that the unit of measure, “Hz”, should be distributed among them?
\newcommand\foo{,\linebreak[0] }then use\foorather than,between your numbers. – David Carlisle Oct 04 '18 at 23:17