We show how one can implement a quantum heat machine by using two interacting trapped ions, in presence of a thermal bath. The electronic states of the ions act like a working substance, while the vibrational mode is modelled as the cold bath. The heat exchange with the cold bath is mimicked by the projective measurement of the electronic states. We show how such measurement in a suitable basis can lead to either a quantum heat engine or a refrigerator, that undergoes a quantum Otto cycle. The local magnetic field is adiabatically changed during the heat cycle. The performance of the heat machine depends upon the interaction strength between the ions, the magnetic fields, and the measurement cost. In our model, the coupling to the hot and the cold baths are never switched off in an alternative fashion during the heat cycle, unlike other existing proposals of quantum heat engines. This makes our proposal experimentally realizable using current tapped-ion technology.