First you should probably use createrawsendfrom rather than createrawtransaction, since that will automatically select the inputs to spend for you. In order to do this the address from which you're preparing the transaction to send needs to be added to the node using importaddress.
To do this for publishing offchain data, specify the createrawsendfrom command's data parameter as an array with a single element that follows one of the stream item formats in this section:
As described in that section, add "options":"offchain" in the stream item object to publish as an off-chain item. At the time of calling createrawsendfrom the off-chain data will be added to the local node's storage, and the transaction prepared (but not yet signed) will include the hash referencing that data.