The idiom "off-and-on" (or on-and-off) is adjectival, in the sense it may be used attributively or as a complement
Her on-and-off boyfriend...
Their relationship was off-and-on that year.
But "from time to time" is a prepositional phrase.
He plays tennis from time to time.
Because one is an adjective, and the other is a PP, one can't be substituted by the other.
The meaning is also different. If someone "plays football on-and-off" it means that there are periods when they don't play football at all, and other periods when they do
on off on
. . . . . .. .. . . ..
But if they play football from time to time, it means irregularly, and not often
time time time time time
. . . . .