The DOD regulations state the following:
Section 4.3.3: All members permanently assigned to live in single Government quarters ashore and in grades E1 through E6 shall be entitled to BAS and may also be assigned to ESM. Enlisted members assigned to ESM shall be charged for all meals the U.S. Government makes available. Charges (at the discount meal rate) shall be directly deducted from the member’s pay account. If assigned duties or dining facility exigencies prevent the Government from providing meals, charges shall be adjusted for affected meals. Members assigned to ESM shall not have meal charges deducted from pay when on leave, on permanent change of station (PCS) status, in the hospital, or on temporary duty (TAD/TDY) other than TAD/TDY to sea duty, field duty, EUM, or group travel.
You are not entitled to it if you are still in basic training, are AWOL, in excess leave status, on educational leave or are under court martial. It also says:
DOD regulation 1418.05, Section 4.2: All members shall pay for any meals the Government furnishes while they are also entitled to BAS. The individual member may pay for meals or, in certain circumstances, have the amount deducted from their pay account or reduced from their travel per diem.
So, BAS yes, BAH no.