Although the Wald entropy is commonly suitable for the first law of black hole thermodynamics, whether it satisfies the second law has not been examined sufficiently. For any high-order curvature gravity, the Wald entropy has been shown not to obey the linearized second law, and the general expression of entropy of black holes that always satisfies the linearized second law is further obtained. For gravity with nonminimal coupling matter fields, however, whether the Wald entropy of black holes satisfies the second law has not been studied enough. Recently, a general second-order scalar-tensor gravitational theory has been proposed. The Lagrangian of the gravitational theory is a linear combination of four components, and the Wald entropy can also be written as four parts. We should investigate each part of the expression separately to examine whether the Wald entropy satisfies the linearized second law. For the first and fourth parts contributed by two nonminimal coupling terms in Lagrangian contained in Horndeski gravity and Gauss-Bonnet gravity, the entropy of black holes is not expressed as the Wald entropy because the entropy in Gauss-Bonnet gravity is Jacobson-Myers entropy. The third part contributed by the Lagrangian in Einstein-Hilbert action is Bekenstein-Hawking entropy, which obeys the second law automatically. Therefore, to obtain the entropy of black holes that meets the linearized second law, we only need to study the second part of the Wald entropy. According to the null energy condition and the Raychaudhuri equation, one can show that the second part of the Wald entropy with correction terms will increase monotonically constrained by the null energy condition during the perturbation process. The second part of the Wald entropy should be modified to satisfy the linearized second law, and the expression of the entropy of black holes, which always obeys the linearized second law, is obtained in the general second-order scalar-tensor gravity.