You need to define an appropriate grouping for your sub-algorithm. Here's the way:

\documentclass{article}
\usepackage{algorithm,algpseudocode,amsmath}
\algnewcommand{\algorithmicsubalgorithm}{\textbf{sub-algorithm}}
\algdef{SE}[SUBALG]{SubAlgorithm}{EndSubAlgorithm}{\algorithmicsubalgorithm}{\algorithmicend\ \algorithmicsubalgorithm}%
%\algtext*{EndSubAlgorithm}% If you want to avoid seeing "end sub-algorithm"
\algnewcommand{\algorithmicinput}{\textbf{Input:}}
\algnewcommand{\algorithmicoutput}{\textbf{Output:}}
\algnewcommand\Input{\item[\algorithmicinput]}%
\algnewcommand\Output{\item[\algorithmicoutput]}%
\begin{document}
\begin{algorithm}
\caption{my algorithm}
\textbf{Input:} All paths \\
\textbf{Output:} Best path.
\begin{algorithmic}
\State $\text{CurrentSelectedPath} \gets \{\}$
\State\textbf{sub-algorithm}
\Statex \hspace{\algorithmicindent} $h \gets \text{allPossible}$
\While{condition}
\State text
\EndWhile
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{my algorithm}
\begin{algorithmic}
\Input All paths.
\Output Best path.
\State $\text{CurrentSelectedPath} \gets \{\}$
\SubAlgorithm
\State $h \gets \text{allPossible}$
\While{condition}
\State text
\EndWhile
\EndSubAlgorithm
\end{algorithmic}
\end{algorithm}
\end{document}
The new block is denoted by \SubAlgorithm...\EndSubAlgorithm (the end-clause can be avoided/removed by uncommenting the appropriate piece of code). It would be possible to make \SubAlgorithm take an argument that could be used as the descriptor for the sub-algorithm, say.
You'll notice that I also took the liberty of cleaning up some other content in your algorithm; this should provide some consistent look-and-feel, and also be easier to update.
Here is an implementation that allows you to name the \SubAlgorithm{<name>}...\EndSubAlgorithm section:

\documentclass{article}
\usepackage{algorithm,algpseudocode,amsmath}
\algnewcommand{\algorithmicsubalgorithm}{\textbf{sub-algorithm}}
\algdef{SE}[SUBALG]{SubAlgorithm}{EndSubAlgorithm}[1]{\algorithmicsubalgorithm\ \textsc{#1}}{\algorithmicend\ \algorithmicsubalgorithm}%
%\algtext*{EndSubAlgorithm}% If you want to avoid seeing "end sub-algorithm"
\algnewcommand{\algorithmicinput}{\textbf{Input:}}
\algnewcommand{\algorithmicoutput}{\textbf{Output:}}
\algnewcommand\Input{\item[\algorithmicinput]}%
\algnewcommand\Output{\item[\algorithmicoutput]}%
\begin{document}
\begin{algorithm}
\caption{my algorithm}
\begin{algorithmic}
\Input All paths.
\Output Best path.
\State $\text{CurrentSelectedPath} \gets \{\}$
\SubAlgorithm{First}
\State $h \gets \text{allPossible}$
\While{condition}
\State text
\EndWhile
\EndSubAlgorithm
\SubAlgorithm{Second}
\State $h \gets \text{allPossible}$
\While{condition}
\State text
\EndWhile
\EndSubAlgorithm
\end{algorithmic}
\end{algorithm}
\end{document}