Let E be the midpoint of OA and F be the midpoint of OB.
If point O is placed between A and B, then points E and F are placed on different sides from O. The segment OE has length 12÷2=6 cm and segment OF has length 9÷2=4.5 cm. Than EF=6+4.5=10.5 cm.
If point O is placed outside the segment AB, then point B is closer to point O than point A, because OA>OB. Since OE=6 cm and OF=4.5 cm, EF=6-4.5=1.5 cm.