Back in his Will & Grace days he just went by Sean Hayes, no middle initial. He’s had some work since W&G and, as far as I know, he didn’t use his middle initial then.
But he has a new show coming out on NBC this fall and in all the promos his middle initial is being used.
Could be that the actor had to join a union that the musician is in (musicians union? Stage actors guild?) and the musician got there first with the name.