The Headmasters are charmed to appear once they die, or retire I suppose, unless they quit ignobly like Snape, but I can't think of anything else we know canonically about portraits.

What do we know about portrait... tech? How do they talk? Do they always talk?

Are they painted after the person has died? Are they painted before the person has died but charmed afterwards? Is there no physical painting required but something else (hair, blood) that goes on to the canvas and later creates the image of the person?