I am puzzled by your use of the term "second order derivative". Second order derivative of what?
In order to solve the non-homogeneous, linear equation, L(y)= f(x), where "L(y)" is the "left side of the equation"- all terms that involve y or a derivative of y, up to any order, not necessarily just two, we first solve the corresponding homogenous equation: L(y)= 0. I think "L(y)= 0" is what you mean but that is not necessarily "setting the second order derivative to 0".
In any case, if the "right side of the equation", the terms that do not involve y or any of its derivatives, is of the form , then you should try a particular solution of the form where A and B are to be determined.
(Of course, if either or is a solution to the associated homogenous equation (if the coefficients of the equation are real numbers, then if one is a solution, the other must be also), then you should try a solution of the form .)