according to cryptonote standard #4,"- key_offsets: The list of offsets in the global array of outputs of type txout_to_key having the same amount as the input. The first value is the ordinal number of the first referenced output among those having the same amount. Each of the following values is the offset of the next referenced output relative to the previous one. One of the outputs referenced is the actual output being spent, " Where is the global array of outputs of type txout_to_key?
When you read in the blockchain from scratch, your daemon will start building a table of each output encountered in chronological order. Prior to RingCT, outputs had cleartext amounts. RingCT outputs have the amount '0' assigned to them. Outputs are looked up by both their amount and offset. This means that an output with amount 0 at the 3rd offset would be the 3rd ever output observed which had an amount 0.
Therefore, if you want to look up a key_offset, you need to query your daemon's database. You can make an RPC call to do this, using the "get_outs" method.