Niantic have announced that Pokemon GO players will be able to switch teams after 26 February 2019, but the feature will have a few constraints to prevent massive team hopping. Just make sure your Pokemon are not farming while switching.
Players will be able to switch their Pokemon GO team once the update comes on 26 February 2019, but they will be able to do so only once every year. The limitation is likely in place to prevent excessive team hopping which could potentially ruin players' experience in the future.
Another limitation that was set in place will be the cost of switching teams. In order to change their affiliation, players will need to purchase a Team Medallion from the shop, which will cost 1.000 PokeCoins. Players can either farm the points up at the pace of a snail or shell out real life money for it, which will set them back around $8 to $10, depending how they look at it.
This particular amount of PokeCoins itself costs about $8 when converted, but players can't purchase just 1.000 coins and 1.200 is the closest amount to that. This bundle costs $10, and while the extra coins could be used for something else, players are still forced to pay $10.
Anyway, switching teams may indirectly cost players some PokeCoins as well. In case they have a Pokemon at a gym at the time of switching teams, the Pokemon will stay there until defeated and upon returning, it will not bring any PokeCoins along.
Similarly, players can't battle their own Pokemon so if they visit a gym one of their Pokemon are defending, it will be immediately returned to them, with no PokeCoins whatsoever.
Still, the penalties don't seem to harsh at the moment, but it remains to be seen how the community will react at the price of Team Medallions. You can read the official announcement on the website and try to fish for details on your own, or discuss the change on the Pokemon GO subreddit.