You can either use the torque forumula, or draw a picture and use geometry to find the angle. Imagine that the ramp is not there and that something is holding the bottom corner in place. At certain angles the gravity force vector will be the the left of the pivot point and the box will rotate one way. At other angles, the gravity force vector will on the right side of the pivot point and the box will rotate the other way. Where would the gravity force vector be pointing relative to the pivot point to just balance the box, just before it tips one way or the other? If you can picture that, then geometry will give you the answer.
If you need to use vectors and torque equations, then what is the torque at the balance point just before the box tips? That gives you one side of the equation (the torque). What goes into the sin() is not just the ramp angle theta. It is the angle between the gravity vector and the radial vector from the center of gravity to the pivot point that goes into sin(). You need to relate that angle to theta. So some function of theta will be inside the sin().