The most historically accurate spelling is the common 19th century one, Okeh, which was disfavored to disguise the native American origins of the term. See here: http://www.illinoisprairie.info/chocokeh.htm . The pronunciation of "Okeh" is "okay", so the spelling "okay" is more phonetically accurate, and might be preferred on those grounds.
The acronym "OK" is a made-up thing partly to support frontiersman Andrew Jackson and his running mate Martin Van Buren, and it was given a bunch of false acronym associations. The term was never an acronym, but it sounds like one. 19th century people, and many 20th century ones, knew it was frontier Choctaw.
So you use OK if you want to pretend its an acronym, and okay if you don't want to do that. I personally think the correct spelling one should use is the clearly native American okeh, but, to my shame, I always use "Ok" (one capital), since "OK" sounds like shouting, and either "okay" or "okeh" take two keystrokes longer to type.