Alternating diarrhea and constipation is always a difficult problem to deal with in patients with IBS especially if the diarrhea is provoked by laxatives and the constipation by antidiarrheals. In other patients there seems to be a spontaneous switch between the two problems.
Your specific question is about the use of loperamide and this is an extraordinarily safe drug with very few side effects. About the only problem you can get with loperamide is constipation and that usually means you are taking too much. In the UK loperamide comes in the form of capsules (Imodium) and I often tell patients to pull the capsule apart and the contents can then be divided into a half, a third or a quarter.
They can then experiment and find out which dose gives them control without constipation: for instance, a quarter taken twice a day. Indefinite dosing with loperamide is perfectly reasonable as long as you avoid constipation although that will always go away once you stop the drug.