It is true that a first-order sentence, which is preserved by finite direct products, is also preserved by infinite direct products; see Corollary 6.7 of S. Feferman and R. L. Vaught, The first order properties of products of algebraic systems, Fund. Math. 47 (1959), 57-103.

In H. J. Keisler's terminology, a first-order sentence is called a *product sentence* if it holds in a product $X\times Y$ whenever it holds in $X$ and $Y$, a *factor sentence* if it holds in $X$ and $Y$ whenever it holds in $X\times Y$. If memory serves, rather complicated characterizations of product sentences and factor sentences were found by Keisler in the 1960s; the work of Keisler's student J. M. Weinstein may also be relevant. I'm pretty sure the results or at least the references are in the book *Model Theory* by C. C. Chang and H. J. Keisler. (I happen to have at hand a reference to Weinstein's dissertation: Joseph M. Weinstein, First order properties preserved by direct product, University of Wisconsin, Madison, 1965.)

Now, if you wanted to know which first-order sentences are preserved by *reduced* products (direct products reduced modulo a filter on the index set, like ultraproducts but with any old filter instead of an ultrafilter), the answer (also due to Keisler) is very nice: a first-order sentence is preserved by proper reduced products if and only if it's logically equivalent to a Horn sentence. ("Proper" here means that the index set is nonempty and the filter is a filter of nonempty sets; if you want to include improper reduced products, insert "strict" before "Horn sentence".) I'm sure this is discussed in the Chang-Keisler book.