When team A scores a touchdown, the 40 second clock starts running for the try. Then there is no play clock until the referee whistles the free kick ready for play - which is 25 seconds. Then, after the kickoff - the 40 second clock starts again for the ensuing scrimmage play.
It's really no more complicated than that.