A metric transformation is a tool to find a new theory of gravity beyond general relativity. The gravity action is guaranteed to be free from a dangerous Ostrogradsky mode as long as the metric transformation is regular and invertible. Various degenerate higher-order scalar-tensor theories (DHOST) without extra degrees of freedom have been found through the metric transformation with a scalar field and its derivatives. In this work, we examine how a matter coupling changes the degeneracy for a theory generated from the Horndeski theory through the metric transformation with the second derivative of a scalar field, taking a minimally-coupled free scalar field as the matter field. When the transformation is invertible, this theory is equivalent to the Horndeski theory with a higher-order derivative coupling to the matter scalar field. Working in this Horndeski frame and the unitary gauge, we find that the degeneracy conditions are solvable and the matter metric must have a certain structure to remove the Ostrogradsky mode.