Yeah you can. anova() can be used for model comparison whenever two nested models are fitted to the same set of data. In this case you wish to compare a linear model
$y = \beta_0 + \beta_1 x$
with a quadratic model
$y = \beta_0 + \beta_1 x + \beta_2 x^2$
As long as nothing is different between the two model apart from the presence of the quadratic term ($\beta_2 x^2$) then this is a perfectly reasonable comparison to make.
(Strictly speaking, it should still be a reasonable comparison to make if there were other variables added in the quadratic model too, but it would no longer be a test of whether a model with a quadratic term is a better fit to the data than one with only a linear term.)
Edit: As fcop has pointed out. It's only appropriate to use anova() for comparisons between mixed effects models (such as those produced by lme() and g/lmer()) when they have been fit using maximum likelihood, rather than with REML.