There are 2 aspects to allegience.
1. Planets distance from home world. The majority will have 35% maximum, depending on the map.
2. Culture broadcasting. Building culture structures keeps your allegience at maximum, by pushing back the enemies.
As a rule, I build 1 culture on each planet.
However, where I build a block point to an enemy, I tend to put as many as that planets logistics will allow.
I've had 7 on one planet and been broadcasting so much culture the nearest enemy planet revolted.
I've also had 3 on one planet and nearly lost it because the nearest enemy planet had 5. When I added 3 more, the effect reversed, but I was down to 3% before it reversed. A good while later in the game, the planet that nearly caused mine to revolt, revolted itself

So how many culture you build depends on the type of game your playing, and how close the enemy is to the planet your building on.
I also tend to place more around blocking points. Maximum on the block point, and at least 3 on the 2 nearest planets, to reinforce it. Otherwise, if you get an enemy building 5 on every planet, even your 7 will get overwealmed eventually.
Of course, where enemy culture is too high, thats a goal to take out asap with a suitable fleet. You find out how many they have by scouting.