Let me note that there is not any typographical rule that states that the below method is any way correct. It can merely be used if one wishes to control the dash's placement.
One way to do this is to add a command which adds a non-hyphenated dash.
This can be done with \nobreakdash. However, this will not allow any hyphenation until the next word (i.e. no hyphenation in the axis word). Thus one should add a space which breaks the words
A solution would be
% Requires amsmath package
\def\dirdash{\nobreakdash-\hspace{0pt}}
This will show this:
\documentclass{article}
\usepackage{geometry,amsmath}
\geometry{paperheight=5cm,paperwidth=6cm,textheight=3cm,textwidth=4cm}
\def\dirdash#1{\nobreakdash#1\hspace{0pt}}
\begin{document}
Hello, this is the a $x$-axis
Hello, this is the a $x$\dirdash-axis
Hello, this is the a $x$-longword
Hello, this is the a $x$\dirdash-longword
\end{document}
And yield the following output
