you need to be calling that more than once, as in every expand/collapse.
if you move it to callbacks, like keydown, it should fire automatically.
personally, i would put the update code in a function and name it something like updateAria(). you can then easily call updateAria() from anywhere, after something changes, to apply the correct attributes to the new situation.
you might find it easier to make your own "plugin" that does everything you need in one call, replacing the usual show/hide methods.
.attr("aria-expanded", false) ;
.attr("aria-expanded", true) ;
now, you can just call .hideAria() instead of hide() and it does the same thing, but also the aria stuff you need, all in one pretty little package that can be used all over your site.
you will have to customize the actual aria code to hit the right child/parent/etc, but this "plugin" approach itself is a real timesaver long-term.