By the way can be used in many context. As some have correctly identified, Fra l'altro is a correct translation. Another equivalent is Comunque or ad ogni modo which can also obtain a different meaning (literally, comunque means anyway, and so does ad ogni modo). In italianItalian, the three of them can all be used as a translation for by the way:
- By the way, I told him not to worry. - Comunque/Ad ogni modo, gli ho detto di non preoccuparsi.
- Let's talk about Francesco who, by the way, is her husband. - Parliamo di Francesco che, tra l'altro/comunque, è suo marito.
A proposito can still be used in the second case, but is a rather awkward translation for the expression by the way.