In a more rigorous perspective, the relevant object is $\hat{\phi}(f)$ that is formally interpreted as $$\hat{\phi}(f):= \int \hat{\phi}(x) f(x) d^4x$$ It is the field operator smeared by the test function $f$, any smooth compactly supported real function $f$ defined in the spacetime.
In fact, $\hat{\phi}(f)$ is a densely defined Hermitian operator in the Hilbert space for every such $f$.
(Technically speaking, the associated observable is the closure of that operator. However there is a dense invariant domain in common for all operators $\hat{\phi}(f)$ when varying $f$, and the closure on that domain defines the saud selfadjoint operator. I will assume to deal with this domain henceforth.)
The commutation relations written into a rigorous version are $$[\hat{\phi}(f), \hat{\phi}(g)]= 0\quad \mbox{if the supports of f and g are causally separated}$$ Here we are considering the commutation relation of proper observables. These represent observables localised in regions defined by the supports of the two smearing functions. In turn, these sets are causally separated.
These observables should be compatible since, for obvious causal reasons, their measurements cannot disturb each other. Compatibility, in the standard version of QM, is equivalent to commutativity of the spectral measures which, on suitable invariant domains implies commutativity of the same observables. This justifies the above commutation relations.
Formally, we can also write $$0= [\hat{\phi}(f), \hat{\phi}(g)] = \int\int [\hat{\phi}(x), \hat{\phi}(y)] f(x)g(y) d^4xd^4y.$$ Arbitrariness of $f$ and $g$ should imply $$[\hat{\phi}(x), \hat{\phi}(y)]=0$$ when $x$ and $y$ are causally separated, though this identity is just a shorthanded version of its rigirous version written above.