In this specific context, if and when actually have slightly different connotations. As Kristen Ramos said, both are substantially correct; your meaning will be understood in either case. That said, the if-version is the preferred way to give advice about a specific, imminent situation.
If you are going to the dentist, you should brush your teeth.
means something like
If you are going to the dentist [right now, as I think you are], you should brush your teeth.
Here, the scope of the if (the ‘right now’) is understood from context. You don't mean (and a native speaker wouldn't mistake you as meaning) ‘if you're ever going to the dentist.’ In contrast,
When you are going to the dentist, you should brush your teeth.
is open to at least two interpretations, both of which are unnecessarily general for your situation:
1) When you are going to the dentist [whenever that happens to be], you should brush your teeth.
2) Whenever one is going to the dentist, one should brush one's teeth.
When is very frequently used in this second sense, to describe a general rule or principle. This means that
Children, when you are going to the dentist, you should brush your teeth.
is the preferred form for your second example, because the speaker is dispensing broad advice not tied to a particular situation.