The angles \( \alpha, \beta, \gamma \) made by the line with the \( x \)-axis, \( y \)-axis, and \( z \)-axis respectively, satisfy the equation for direction cosines:
\[
\cos^2 \alpha + \cos^2 \beta + \cos^2 \gamma = 1.
\]
Given that \( \alpha = \frac{\pi}{4} \) and \( \gamma = \frac{\pi}{4} \), we calculate:
\[
\cos \alpha = \cos \gamma = \frac{\sqrt{2}}{2}.
\]
Substitute these values into the equation:
\[
\left(\frac{\sqrt{2}}{2}\right)^2 + \cos^2 \beta + \left(\frac{\sqrt{2}}{2}\right)^2 = 1.
\]
Simplify:
\[
\frac{1}{2} + \cos^2 \beta + \frac{1}{2} = 1 \quad \Rightarrow \quad \cos^2 \beta = 0.
\]
This implies:
\[
\cos \beta = 0 \quad \Rightarrow \quad \beta = \frac{\pi}{2}.
\]
Final Answer: \( \boxed{\frac{\pi}{2}} \).