For fields made out of plane waves, integration by parts can be justified in all circumstances by imposing periodic boundary conditions. In the limit that the periods become long, you recover the ordinary infinite space theory, and in periodic boundaries, integration by parts has no boundary terms.
Quantum fields don't have a real number value, except when you look at some particular state and ask for their expectation. They are like other quantum mechanical operators. So integration by parts can work for the fields, even if there are particular configurations which do not vanish at infinity. For integration by parts to work for the quantum fields, it doesn't have to work for every classical field configuration.
Quantum fields are tempered distributions, which are those distributions which have a Fourier transform of the same kind. Integration by parts is fine for tempered distributions, because in Fourier space, terms which are equal by integration by parts are just plain equal.
For the special case you are considering, the integration by parts is for the term:
$$\int \partial_i \dot\phi \partial_j \phi - \partial_j \dot\phi \partial_i \phi $$
Which gives a boundary term equal to
$$ \int \partial_i ( \dot\phi \partial_j \phi ) - \partial_j(\dot\phi \partial_i \phi) $$
This boundary term gives the nonzero part of the commutator of two momentum operators. It is zero for oscillating configurations, whose Fourier transforms are well defined tempered distributions. For a plane waves, the two terms are equal products of wavenumbers.
But if you have a classical field which is of the form
$$ \phi_\mathrm{cl} = xt $$
Then the boundary term gives a nonzero value. Such a classical configuration is not reachable from the vacuum, because it requires an impossible infinite fluctuations to appear, but you can impose it as a background, around which you quantize. But in this case, you write the field in the path integral as a sum of two terms
$$ \phi = \phi_{cl} + \phi_\mathrm{q}$$
and the path integral is over the quantum part of the field $\phi_\mathrm{q}$. Integration by parts will work for the quantum part, even though it doesn't work for this particular classical background. This is ok, because the classical background doesn't have a nonzero commutator with anything, and you can still integrate by parts to prove commutation identities.