The codimension of $X=Z(f_1,\ldots,f_k)$  in $\mathbf{A}^n$ equals $k$, or equivalently,  the dimension of $X$ is $n-k$,  if  $(f_1,\ldots,f_k)$ is a regular sequence. 

Let me explain what a regular sequence is. Sorry if I'm writing things you already know.

Let $A$ be a noetherian ring. An element $x\in A$ is called *regular* if the multiplication by $x$ is injective. A sequence $(x_1,\ldots,x_n)$ of elements $x_1,\ldots,x_n\in A$ is said to be a *regular sequence* if $x_1$ is regular and the image of $x_i$ in $A/(x_1A+\ldots+ x_{i-1}A)$ is regular for all $i=2,\ldots,n$. 

You can use Krull's principal ideal theorem to show that any ideal $I$ of $A$ which can be generated by a regular sequence $(x_1,\ldots,x_r)$ satisfies $\textrm{ht}( I) = r$.

So one way to find out if the dimension of $X$ is $n-k$ is to check the above condition. 

If $k=1$ and $f_1\neq 0$ we're good.

Let's see how it goes for $k=2$. Let's suppose that $f_1\neq 0$ and that $f_2 $ is not contained in the ideal $(f_1)$. Now, you have to check that the image of $f_2$ in $k[x_1,\ldots,x_n]/(f_1)$ is regular. So you  compute the quotient and check if it's an integral domain. If it's an integral domain, we're good. If not, it might be a bit more difficult to check if $f_2$ is regular in $k[x_1,\ldots,x_n]/(f_1)$. I wouldn't know a fast way of checking if this element is a non-zero divisor at the moment. 

This is not a complete answer but I hope it at least helped a bit.