We study the family of piecewise linear differential systems in the plane with two pieces separated by a cubic curve. Our main result is that 7 is a lower bound for the Hilbert number of this family. In order to get our main result, we develop the Melnikov functions for a class of nonsmooth differential systems, which generalizes, up to order 2, some previous results in the literature. Whereas the first order Melnikov function for the nonsmooth case remains the same as for the smooth one (i.e. the first order averaged function) the second order Melnikov function for the nonsmooth case is different from the smooth one (i.e. the second order averaged function). We show that, in this case, a new term depending on the jump of discontinuity and on the geometry of the switching manifold is added to the second order averaged function.