How can I force my companion to focus on healing instead of attacking enemies?
Solution 1:
In Theory You should be able to do this by turning off auto-cast on all of your companions offensive abilities. You can do this by expanding their action bar (click the + on the right hand side of the 4 button action bar in their unit frame, at the bottom left of your screen.) See that green square in the top right corner of each spell? That's auto-cast. Right clicking on the spell will turn that off, and the square will become empty (black). Once auto-cast is off for a spell, your companion should never use it unless you specifically command them to (by actively clicking on that spell from their bar).
The reason this answer starts with in theory however, is because in practice, your companion will sometimes have all of their healing abilities on cooldown (or you will be topped off), at which point they might perform their basic attack.