The works in view in Ephesians 2:8-9 may be the works of the law, i.e actions in obedience to the law. Paul tells us by the law, no one is justified, so salvation is not based on our efforts to obey the law.
A second question is "what law." The law of Moses, or the natural law written on our heart. Romans 2 teaches both of these types of laws are in view.
Note also that "works" is plural, so the idea is doing things, like working for a wage, where our salvation is earned. But if it is earned by doing works, then it is not by grace. So this view opens the door for the idea that we can do a work, singular, the work God requires of us, and that is to believe in the One God sent.
Because the folks ask what work they can do, and Jesus answers with a singular work, the best understanding of the verse is Jesus is saying what work God requires of them. This view is consistent with Romans 4:4-5 where faith is shown not to be works.