If your function is something like f(x,y)= Ax^2+ Bxy+ Cy^2+ linear terms, there are two methods of doing this, one involving more calculation, the other "deeper" and more sophisticated.
The one involving more calculation is this: let x= x'cos(\theta)+ y'sin(\theta) and y= -x'sin(\theta)+ y'cos(\theta). Put those into the formula so that you have x'^2, x'y', and y'^2, each with coefficients depending on known number A, B, C, and \theta. Set the coefficient of x'y' equal to 0 and solve for \theta.
More sophisticated: write f(x,y)= Ax^2+ Bxy+ Cy^2 in matrix form:
\begin{bmatrix}x & y\end{bmatrix}\begin{bmatrix}A & B/2 \\ B/2 & C\end{bmatrix}\begin{bmatrix}x \\ y \end{bmatrix}
and solve for the eigenvalues and eigenvectors for that 2 by 2 matrix. Since it is a symmetric matrix, it has real eigenvalues and 2 independent eigenvectors. If you take the new x', y' axes in the direction of the eigenvectors, the matrix becomes diagonal, having the eigenvalues on the main diagonal so that your equation becomes
\begin{bmatrix}x' & y'\end{bmatrix}\begin{bmatrix}\lambda_0 & 0 \\ 0 & \lambda_1\end{bmatrix}\begin{bmatrix}x' \\ y'\end{bmatrix}= \lambda_0x'^2+ \lambda_1y'^2