Can I have a sub panel right below the attic access?
As Steven said, it depends on the applicable code. I doubt any code is going to be that specific. So it will be up to the local authority having jurisdiction to interpret what the code does say and decide if it applies to your situation. As such, no one here can accurately answer this unless they happen to represent your LAHJ.

For example, the NEC simply says that over-current devices be readily accessible. Readily accessible in part is defined as devices need to be able to be quickly operated without the need to remove any obstacles. So the attic access alone would seem to comply as it does not affect access to the breakers.

However, to effectively use an attic access, one must place a ladder, which could block access to the breakers, requiring removal before operation is possible. This would cause the panel location to not comply.

In cases of contradicting interpretations, the LAHJ must decide what interpretation best represents the code's intent. Since access to breakers could be most important when someone is working in the attic with a ladder in place, I personally would rule that this arrangement is not in compliance. But I am not your LAHJ.

The short answer is you have to ask your electrical inspector.