see inside
you can work until your OPT expires. you can file your H4 application one day before opt expires or even after it expires. H4 will start from your OPT expiration date if it is approved after the OPT expiration date. however, i am not sure whether you can apply the H4 starting date if H4 approved before OPT expiration date (check the form for that). anyway, H4 application takes quite at least 2-3 months to be approved (check www.ins.gov for current processing date).
good luck.