How to account for moderator variables in propensity score matching or exact matching? For example, in my current project assessing the impact of health care intervention on # hospital inpatient visits compared with a control group, age and sex are moderators that could influence the relationship between the intervention and the outcome.
Is standard practice to match on moderator variables just as you would a confounder?
Or match on interaction effects for moderators and confounders (e.g., age_category $\times$  healthy_living_motivation_score and sex $\times$ healthy_living_motivation_score)?
I would think by default if you match on a moderator and a confounder, you are also matching on the interaction effect of the two variables.

In order to perform moderation, you need to be able to validly estimate subgroups effects, which means confounding needs to be removed within subgroups of the moderating variable. In the context of matching, this means you must exactly match on the moderator, or equivalently, match within subgroups of the moderator (i.e., performing a separate matching routine within each subgroup).
To estimate the treatment effect, you can fit a model that include an interaction between the moderator and all other variables in the model (including the treatment and any treatment-by-covariate interactions), then perform a marginal effects procedure within subgroups. To assess whether moderation is present, you can test whether the subgroup treatment effects differ from each other.
Some useful resources on moderation analysis: Green and Stuart (2014), Griffin et al. (2022), the MatchIt vignette section on moderation analysis.
