When should we use splines in regression? What's the justification? I am examining the direct causal effect of x on y.
Let's assume we a model as follows
y ~ x

Shows no significant effect of x on y. The reason may be that x variable has extreme values (5 data points) that should not be excluded from dataset (they are not measuring errors). The distributions of x and y variable variable are lognormal.
y ~ s(x)

Shows nonlinear significant effect of x on y

Thus, I should use splines since there is a nonlinear relationship between x and y? Is my understanding correct?
EDITED AFTER ANSWERS
Splines model has clearly better AIC. Plotting raw data and eyeballing these plots shows a similar non-linear relationship. I expect the relationship to be non-linear in real life/nature.
 A: There is a lot more to modelling than relying on the statistical significance of an association. I think it would be helpful if you graphed the two variables so as to get an eyeball on the possible association between them. There are also statistical tests to assess which of the two models provides a better fit to the data. You could use something like AIC or ANOVA based on deviance. You could do this using the R package mgcv.
library(mgcv)

mod.l <- gam(y ~ x, data = my.data)

mod.nl <- gam(y ~ s(x), data = my.data)

AIC(mod.nl, mod.l)

anova(mod.nl, mod.l, test = "Chisq")

I am assuming a gaussian distribution for x, otherwise use family = " " inside gam() with the appropriate distribution. Check the documentation for mgcv.
You can also ask yourself if the modelling results make sense based on the above. For example - do you have previous information that indicates the nature of an association between two variables.
The graph you displayed does not actually show the data points. The plot you displayed but including residuals would be helpful for you to assess the model fit. mgcv also has functions to assess residuals - see the documentation for gam.check.
I hope this helps.
