If you are creating automatic stimulus using the randomize() method and you need a value to be one-hot, you can use the built in $onehot assertion. This assertion returns a 1 if the value inside it is a one-hot. The assertion looks like this:
assert(myreq.randomize() with{
$onehot(onehot_reg) == 1;});
This code will clear all the bits in onehot_reg then randomly set one of them.