As Herbert was implying, it's not possible with \underline{}, use either the package soul and its \ul{foo} command, or the package ulem, which changes \emph{foo} to use underlining. There's more information on hyphenating underlined text on the TeX FAQ:
Knuth made no provision for underlining text: he took the view that
underlining is not a typesetting operation, but rather one that
provides emphasis on typewriters, which typically offer but one
typeface. The corresponding technique in typeset text is to switch
from upright to italic text (or vice-versa): the LaTeX command \emph
does just that to its argument.
Nevertheless, typographically illiterate people (such as those that
specify double-spaced thesis styles) continue to require underlining
of us, so LaTeX as distributed defines an \underline command that
applies the mathematical ‘underbar’ operation to text. This technique
is not entirely satisfactory, however: the text gets stuck into a box,
and won’t break at line end.
Two packages are available that solve this problem. The ulem package
redefines the \emph command to underline its argument; the underlined
text thus produced behaves as ordinary emphasised text, and will break
over the end of a line. (The package is capable of other peculiar
effects, too: read its documentation, contained within the file
itself.) The soul package defines an \ul command (after which the
package is, in part, named) that underlines running text.
Beware of ulem’s default behaviour, which is to convert the \emph
command into an underlining command; this can be avoided by loading
the package with:
\usepackage[normalem]{ulem}
Documentation of ulem is in the package itself.
(https://texfaq.org/FAQ-underline)
I can only second that: If you know why you want to use underlining, go ahead; but if not, consider another way of emphasizing your text.