Since it is a custard, you should probably refrigerate it as soon as it is cool. A very sugary or acidic custard may be able to resist bacteria for a couple days (see Bismark donuts), but unless the recipe was specifically developed to be stable at room temperature, then there is some risk of it going bad.