This is an understandable issue. On the one hand we have the case where a single digit is passed as n, and then the recursive call for n/10 should return 0 (as it does now).
On the other hand, if the value n is 0 from the start, it should return 1.
This is a contradiction that you can solve by making 0 a special case in the main program. But this is solved more elegantly by stopping the recursion one step earlier, so not when all digits are gone, but when there is one digit. This you can implement by changing:
if(n==0)
return n;
...to:
if(n<10) // Only 1 digit?
return 1;
This way the function can never return 0, so even for 0 it will return 1.
Remark
It is bit overkill to have the count variable. You can just add 1 to what the recursive call returns:
return 1 + countDigits(n/10);
With a conditional operator, both the base case and the recursive case can be combined in one expression:
public static int countDigits(int n)
{
return n < 10 ? 1 : 1 + countDigits(n/10);
}